The keypress event is not fired in ionic 2 Android applications. The same is working fine with iOS and browser(chrome) platform. My requirement is to restrict the keyboard typing with some characters. ie, Don't want to show that characters which I typed in input field. The following code snippet as follows..
onKeyPress(event) {
const pattern = /[0-9\.\ ]/;
let inputChar = String.fromCharCode(event.charCode);
if (!pattern.test(inputChar)) {
event.preventDefault();
}
}
:HTML
<input type="text" (click)="stopProcess()" (keypress)="onKeyPress($event)" />
The above function is not firing in android. Can anyone suggest me a solution for the same?