Keypress event not getting fired


#1

Hi,
In ionic 3 keypress not getting fired

<ion-searchbar (keypress)=“onKeypress($event)”
[(ngModel)]=“model.autoSearch” showCancelButton=“true”>

keypress event only fired in browser not getting fired in real device.


#2

The keypress event is not available. Instead use ionInput to listen for input changes.

Try this out…

<ion-searchbar (ionInput)="onKeypress($event)"
[(ngModel)]=“model.autoSearch” showCancelButton=“true”>

Although, it really is “on input change” and not really “on key press”.

See Searchbar Output Event docs for more information.

Hope this help! :crossed_fingers:


#3

Thanks for response. but I want charCode which is available in keypress event

<ion-searchbar (keypress)=“onKeypress($event)”
[(ngModel)]=“model.autoSearch” showCancelButton=“true”>

ts
onKeypress(event){
event.charCode();
}

it is working in browser but not working in android.