Keydown event not working in Android

I write a function using KeyboardEvent to let a input only allow number, ‘-’ key and BackSpace key. When I test in ionic serve or ios, it worked. But when I test in Android its not working, input field will allow all the character inputed.
When I use console.log(event), it always returns the key=“Unidentified”, keyCode = 229.

Environment: Ionic 3, Node v6.11, npm 3.10, Android 5.1.1
I dont know how to fix this. I’m a newbie in Ionic, anyone give me advise, plz!

.ts file

import {Component} from '@angular/core';
import {NavController} from 'ionic-angular';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {
  constructor(public navCtrl: NavController) {

  }

  isValidNumber(event) {
    //console.log(event);
    return /\d|-|Backspace/.test(event.key);

  }
}

.html file

<ion-header>
  <ion-navbar>
    <ion-title>Home</ion-title>
  </ion-navbar>
</ion-header>
<ion-content>
  <ion-item>
      <ion-input  type="text" (keydown)="isValidNumber($event)"></ion-input>
  </ion-item> 
</ion-content>
3 Likes

same here but for me its 0 not 229

…Any solution?

any luck with this ?

I have this same problem but only in some versions of android, like android 6.1, any solutions on this topic? event.key is always undefined keyCode is just fine for me.

Any Solution? i’m having same 229 keyCode in android 8.0 with ionic 5