Skip to content
masterclass Buddy

Angular · Decorator

@HostListener

@HostListener connects a class method to a DOM event on the host element. It can also listen on document, window, or body and pass event values to the method.

Last updated

Syntax

@HostListener(eventName: string, args?: string[]);

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • @HostBinding
  • host property
  • KeyboardEvent.key
  • code modifier

Source: HostListener • Angular. Checked 2026-11-03.