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

injectHotkey

Call Signature

ts
function injectHotkey<T>(
   hotkey, 
   callback, 
   options?): void;
function injectHotkey<T>(
   hotkey, 
   callback, 
   options?): void;

Defined in: injectHotkey.ts:70

Angular inject-based API for registering a hotkey: a chord such as 'Mod+S', a sequence such as ['G', 'G'], or an app hotkey from defineAppHotkeys. The hotkey and options may be getters that read signals.

Chords accept requireReset; sequences accept timeout. A one-step sequence registers as its chord. An app hotkey uses its effective hotkey from provideHotkeys (including the user's custom hotkey) and its declared meta and options, and registers nothing while unbound.

Type Parameters

T

T extends AppHotkey<string, HotkeyChord | HotkeySequence | null>

Parameters

hotkey

MaybeGetter<T>

callback

HotkeyCallback

options?

MaybeGetter<InjectAppHotkeyOptions<T>>

Returns

void

Example

ts
@Component({ ... })
export class EditorComponent {
  constructor() {
    injectHotkey('Mod+S', () => this.save())
    injectHotkey(['G', 'G'], () => this.scrollToTop(), { timeout: 500 })
    injectHotkey('Escape', () => this.close(), () => ({ enabled: this.isOpen() }))
  }
}
@Component({ ... })
export class EditorComponent {
  constructor() {
    injectHotkey('Mod+S', () => this.save())
    injectHotkey(['G', 'G'], () => this.scrollToTop(), { timeout: 500 })
    injectHotkey('Escape', () => this.close(), () => ({ enabled: this.isOpen() }))
  }
}

Call Signature

ts
function injectHotkey<T>(
   hotkey, 
   callback, 
   options?): void;
function injectHotkey<T>(
   hotkey, 
   callback, 
   options?): void;

Defined in: injectHotkey.ts:75

Angular inject-based API for registering a hotkey: a chord such as 'Mod+S', a sequence such as ['G', 'G'], or an app hotkey from defineAppHotkeys. The hotkey and options may be getters that read signals.

Chords accept requireReset; sequences accept timeout. A one-step sequence registers as its chord. An app hotkey uses its effective hotkey from provideHotkeys (including the user's custom hotkey) and its declared meta and options, and registers nothing while unbound.

Type Parameters

T

T extends RegisterableHotkey

Parameters

hotkey

MaybeGetter<T>

callback

HotkeyCallback<HotkeyCallbackContextFor<T>>

options?

MaybeGetter<AdapterOptionsFor<T, InjectHotkeyTarget>>

Returns

void

Example

ts
@Component({ ... })
export class EditorComponent {
  constructor() {
    injectHotkey('Mod+S', () => this.save())
    injectHotkey(['G', 'G'], () => this.scrollToTop(), { timeout: 500 })
    injectHotkey('Escape', () => this.close(), () => ({ enabled: this.isOpen() }))
  }
}
@Component({ ... })
export class EditorComponent {
  constructor() {
    injectHotkey('Mod+S', () => this.save())
    injectHotkey(['G', 'G'], () => this.scrollToTop(), { timeout: 500 })
    injectHotkey('Escape', () => this.close(), () => ({ enabled: this.isOpen() }))
  }
}