Keyup not working for PWA angular even after changing from keypress

I have a function to validate in input field / date field. When using (keypress) it is working fine on web but not in mobile. And when I am using (keyup) , the validation is not working in web as well.

What is the permanent solution for PWA Angular for this issue ?

// to validate date in numberic and / only
  keyPressAlphanumeric(event: any) {
    var inp = String.fromCharCode(event.keyCode);
    if (/[0-9_/]/.test(inp)) {
      return true;
    } else {
      event.preventDefault();
      return false;
    }
  }


<input matInput [matDatepicker]="picker"  maxlength="10" [max]="maxDate" placeholder="MM/DD/YYYY" required
                formControlName="DOI" autocomplete="off" (keypress)="keyPressAlphanumeric($event)">