kit-event-manager

API

[class] KitEventManagerService

@Injectable

Provided in:'root'

Service for global events handling.

Example

Handle esc keydown globally:

import { keyEscape, KitEventManagerService } from '@ngx-kit/core';
...
constructor(private em: KitEventManagerService) {
}
...
// subscribe
const escUnsub = this.em.listenGlobal('keydown', (event: KeyboardEvent) => {
  if (event.keyCode === keyEscape) {
    // do the job
  }
}, true);
...
// unsubscribe
escUnsub();

Members

SignatureDescription
listenGlobal(eventName: string, handler: Function, useCapture?: boolean): Function

Listen event on the global root object.

Reason: native Angular EventManager does not provide event listener with useCapture param.

getEventPath(event: Event): EventTarget[]

Get array of objects visited by event.