Pass $event
to your event handler. The $event
is a DOM KeyboardEvent.
<input type=text (keypress)="eventHandler($event)">
eventHandler(event) {
console.log(event, event.keyCode, event.keyIdentifier);
}
If you know which KeyboardEvent property you want, you can pass that into your event handler:
<input type=text (keypress)="eventHandler($event.keyCode)">
eventHandler(keyCode) {...}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…