Angular 9 References/ Templates


This is the documentation for Angular 9.
You can switch to the latest version Angular 10.

You can filter keyboard events in a template by event key.

Angular allows you to directly bind to a specific keystroke or keystroke combination. That means a keyboard event will be only fired on that specific key or key combination instead of on all key events.

<input (keyup.enter)="enterHandler()">
<input (keydown.esc)="escHandler()">
<input (keyup.shift.f)="shiftFHandler()">
export class AppComponent {
  enterHandler() {
    alert('Enter pressed!');

  escHandler() {
    alert('ESC pressed!');

  shiftFHandler() {
    alert('Shift+F pressed!');
Links & Tutorials