How to handle "Go"/"Enter" keyboard button Ionic2 <ion-input>

rubmz picture rubmz · Nov 21, 2016 · Viewed 37.7k times · Source

What is the event to handle "enter" or "go" keyboard key on an input? The input is not used within a form. So clicking on it will not "submit". I just need the event.

(Running android + Ionic 2 on Beta 11)

Answer

sordaria picture sordaria · Jul 23, 2017

I did like this:

<ion-input type="text" [(ngModel)]="username" (keyup.enter)="handleLogin()"></ion-input>

And:

handleLogin() {
    // Do your stuff here
}