Docs
CodeRabbit
Cloudflare
Railway
AG Grid
Clerk
OpenRouter
WorkOS
Netlify
SerpAPI
Prisma
Electric
Sentry
Unkey
CodeRabbit
Cloudflare
Railway
AG Grid
Clerk
OpenRouter
WorkOS
Netlify
SerpAPI
Prisma
Electric
Sentry
Unkey
Hotkeys API Reference
Hotkey Sequence API Reference
Key hold & held keys API Reference
Hotkey Recorder API Reference
Hotkey Sequence Recorder API Reference
Normalization & format API Reference
Hotkeys API Reference

injectHotkeys

Function: injectHotkeys()

ts
function injectHotkeys(hotkeys, commonOptions): void;
function injectHotkeys(hotkeys, commonOptions): void;

Defined in: injectHotkeys.ts:75

Angular inject-based API for registering multiple keyboard hotkeys at once.

Uses the singleton HotkeyManager for efficient event handling. Accepts a dynamic array of hotkey definitions.

Call in an injection context (e.g. constructor or field initializer). Uses effect() to track reactive dependencies and update registrations when options or the callback change.

Options are merged in this order: provideHotkeys defaults < commonOptions < per-definition options

Parameters

hotkeys

Array of hotkey definitions, or getter returning them

[] | () => []

commonOptions

Shared options for all hotkeys, or getter

| () =>

Returns

Examples

ts
@Component({ ... })
export class EditorComponent {
  constructor() {
    injectHotkeys([
      { hotkey: 'Mod+S', callback: () => this.save() },
      { hotkey: 'Mod+Z', callback: () => this.undo() },
      { hotkey: 'Escape', callback: () => this.close() },
    ])
  }
}
@Component({ ... })
export class EditorComponent {
  constructor() {
    injectHotkeys([
      { hotkey: 'Mod+S', callback: () => this.save() },
      { hotkey: 'Mod+Z', callback: () => this.undo() },
      { hotkey: 'Escape', callback: () => this.close() },
    ])
  }
}
ts
@Component({ ... })
export class DynamicShortcuts {
  shortcuts = signal([...])

  constructor() {
    injectHotkeys(
      () => this.shortcuts().map((s) => ({
        hotkey: s.key,
        callback: s.action,
      })),
    )
  }
}
@Component({ ... })
export class DynamicShortcuts {
  shortcuts = signal([...])

  constructor() {
    injectHotkeys(
      () => this.shortcuts().map((s) => ({
        hotkey: s.key,
        callback: s.action,
      })),
    )
  }
}