Ionic 4 - submit form with android keyboard "enter/go"

Anyone knows how to make works, submit a reactive form in android with enter/go key,i need to implement it on my login page but i tried (keypress.enter) and (ngSubmit) but dont work, this is my form:

 <form [formGroup]="loginForm" class="ion-margin-top" (ngSubmit)="loginWithUser()">
                    <ion-row >
                        <ion-col size="12">
                                <ion-item lines="none">
                                    <ion-label position="floating">Email</ion-label>
                                    <ion-input formControlName="email" type="email"></ion-input>
                                </ion-item>
                        </ion-col>
                        <ion-col size="12">
                                <ion-item lines="none">
                                    <ion-label position="floating">Password</ion-label>
                                    <ion-input formControlName="password" type="password"></ion-input>
                                </ion-item>
                        </ion-col>
                    </ion-row>
                    <ion-row>
                        <ion-col>
                            <ion-button (click)="loginWithUser()">
                                Login
                            </ion-button><br>
                        </ion-col>
                    </ion-row>
                </form>

ts

loginWithUser() {
console.log(this.loginForm.value)
}

any help is welcome

You need to add a type to the button.

 <ion-button type="submit">
    Login
 </ion-button><br>

Note : You should remove the (click) from the button as it is defined on the form.

1 Like