Injection of injection into polymer injection

I am trying to detect when a user hits return / enter in a chat box to send a message. How do I define this for an element paper-input

?

+3


source to share


1 answer


document-input inherits from core-input

, which fires an event change

when users press Enter / return or the element loses focus. If you don't care about the loss of focus case (for example, just for the case where the user presses ENTER), you can check document.activeElement

:

document.querySelector('paper-input').addEventListener('change', function(e) {
  if (document.activeElement == this) {
    console.log('ENTER hit on aper-input');
  }
});

      



http://jsbin.com/godaqugacecu/1/edit

See http://www.polymer-project.org/docs/elements/core-elements.html#core-input .

+4


source







All Articles