Skip to content

Commit

Permalink
fix(stark-ui): remove KeybordEvent.char
Browse files Browse the repository at this point in the history
KeybordEvent.char is deprecated and will be remove from typesscript. To prepare the update to
angular 13 we need to remveoved occureneces

ISSUES CLOSED: #3634
  • Loading branch information
mhenkens authored and Unknown committed Sep 22, 2023
1 parent 58c4e7c commit c25fec8
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ export class StarkRestrictInputDirective implements OnInit {
*/
@HostListener("keypress", ["$event"])
public eventHandler(event: KeyboardEvent): boolean {
// some browsers return the special key value (i.e. keys in the numeric keypad), in such cases we use the 'char'
// see: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values
/* tslint:disable-next-line:deprecation */
const key: string = event.key.length > 1 ? event.char : event.key;

return this.testValue(event, key);
// If event.key.length > 1 this means that a non char key was press ie: "Home" or "left"
// we let the default behaviour to those key works and just return `true`
if(event.key.length > 1) {
return true;
}
// if normal char we test the value
return this.testValue(event, event.key);
}

/**
Expand Down

0 comments on commit c25fec8

Please sign in to comment.