Docs
CodeRabbit
Cloudflare
Railway
Netlify
Clerk
AG Grid
WorkOS
SerpAPI
OpenRouter
Electric
Prisma
Unkey
Sentry
CodeRabbit
Cloudflare
Railway
Netlify
Clerk
AG Grid
WorkOS
SerpAPI
OpenRouter
Electric
Prisma
Unkey
Sentry
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
Hotkey Recorder API Reference

injectHotkeyRecorder

Function: injectHotkeyRecorder()

ts
function injectHotkeyRecorder(options): AngularHotkeyRecorder;
function injectHotkeyRecorder(options): AngularHotkeyRecorder;

Defined in: injectHotkeyRecorder.ts:58

Angular inject-based API for recording keyboard shortcuts.

Thin wrapper around the framework-agnostic HotkeyRecorder class: captures keyboard events, converts them to hotkey strings, and handles Escape to cancel or Backspace/Delete to clear.

Parameters

options

Configuration options for the recorder (or getter)

| () =>

Returns

Object with recording state signals and control functions

Example

ts
@Component({ ... })
export class ShortcutSettingsComponent {
  shortcut = signal<Hotkey>('Mod+S')
  recorder = injectHotkeyRecorder({
    onRecord: (hotkey) => this.shortcut.set(hotkey),
    onCancel: () => console.log('Recording cancelled'),
  })

  constructor() {
    injectHotkey(
      () => this.shortcut(),
      () => this.handleSave(),
      () => ({ enabled: !this.recorder.isRecording() }),
    )
  }
}
@Component({ ... })
export class ShortcutSettingsComponent {
  shortcut = signal<Hotkey>('Mod+S')
  recorder = injectHotkeyRecorder({
    onRecord: (hotkey) => this.shortcut.set(hotkey),
    onCancel: () => console.log('Recording cancelled'),
  })

  constructor() {
    injectHotkey(
      () => this.shortcut(),
      () => this.handleSave(),
      () => ({ enabled: !this.recorder.isRecording() }),
    )
  }
}