How to implement ui:inpuText Enter key event in Lightning

You can get the keyCode from the event object .Below is what I tried and worked

({
  searchEvents: function(component, event, helper) {
      console.log(event.getParams().keyCode);
      if(event.getParams().keyCode == 13){
        alert('Enter key pressed');
      }
   }
 })

You can also use which as well .Below is the console.log of whole event object

enter image description here


Here is a lightning code sample. I tried it in an org that has Winter 16 Release deployed.

<aura:application >
    <aura:Attribute name='val' type = 'String' />
    <ui:inputText value='{!v.val}' keyup="{!c.search}" />
</aura:application>

({
    search : function(component, event, helper) {
        if(event.getParams().keyCode == 13){
          alert('Enter key pressed');
            // Do your work here
        }
    }
})