Ionic-cli: keypress event is not working in Android 4.4.2 device for Ionic 2 App

Created on 6 Jan 2017  路  3Comments  路  Source: ionic-team/ionic-cli

I am using keypress event to restrict the special chars in my input. It is going fine with the version lollipop and above, but its not working in Android 4.4.2.
Kindly suggest for this.
Thank You.

Most helpful comment

I too am having a problem in Ionic regarding the keypress (and key) event.

Ionic v 3.12

<!-- Works in the desktop browser, but onPhoneChange() is never called on the Android device. -->
<ion-input type="text" (keypress)="onPhoneChange($event)" required></ion-input>

All 3 comments

I too am having a problem in Ionic regarding the keypress (and key) event.

Ionic v 3.12

<!-- Works in the desktop browser, but onPhoneChange() is never called on the Android device. -->
<ion-input type="text" (keypress)="onPhoneChange($event)" required></ion-input>

Any update on this

keypress is deprecated: https://www.w3.org/TR/DOM-Level-3-Events/#event-type-keypress

Please consider using Angular Form Validation: https://angular.io/guide/form-validation

If you don't want to use validation, you may be able to restrict the characters entered by setting up an ngModel and listen on (input) or (beforeinput) events.

But, this isn't really a CLI issue, so I'm closing this. Please consider creating a topic in the Ionic Forum and seeing what others have to say. (I'm not an Angular expert.)

Was this page helpful?
0 / 5 - 0 ratings