According to this link https://ionicframework.com/docs/api/input#events ionic supports keypress event which is working fine in the browser but in mobile device it is not triggering
html
<ion-item>
<ion-label>Default Label</ion-label>
<ion-input (keypress)="test($event)"></ion-input>
</ion-item>
ts
test(event){
console.log(event);
e.preventDefault();
}
the above code works fine in ionic serve not in mobile device
According to this https://developer.mozilla.org/en-US/docs/Web/API/Document/keypress_event keypress is depricated i am not understanding
Events i tried: keypress, keydown, keyup, ionblur, ionChange, input,..etc Either it is not working or it or preventdefault is not working
According to your own first link I guess you are looking for the event ionInput Emitted when a keyboard input ocurred.
:
<ion-item>
<ion-label>Default Label</ion-label>
<ion-input (ionInput)="test($event)"></ion-input>
</ion-item>
Pass $event to your event handler. The $event is a DOM KeyboardEvent.
<input type=text (keypress)="eventHandler($event)">
eventHandler(event) {
console.log(event, event.keyCode, event.keyIdentifier);
}
If you know which KeyboardEvent property you want, you can pass that into your event handler:
<input type=text (keypress)="eventHandler($event.keyCode)">
eventHandler(keyCode) {...}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With