Docs
Cloudflare
Railway
CodeRabbit
SerpAPI
WorkOS
OpenRouter
Clerk
Netlify
AG Grid
Sentry
Unkey
Prisma
Electric
Cloudflare
Railway
CodeRabbit
SerpAPI
WorkOS
OpenRouter
Clerk
Netlify
AG Grid
Sentry
Unkey
Prisma
Electric
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
Key hold & held keys API Reference

injectHeldKeys

Function: injectHeldKeys()

ts
function injectHeldKeys(): Signal<string[]>;
function injectHeldKeys(): Signal<string[]>;

Defined in: injectHeldKeys.ts:23

Angular inject-based API that returns a signal of currently held keyboard keys.

Subscribes to the global KeyStateTracker and updates whenever keys are pressed or released.

Returns

Signal<string[]>

Signal of array of currently held key names

Example

ts
@Component({
  template: `<div>Currently pressed: {{ heldKeys().join(' + ') || 'None' }}</div>`,
})
export class KeyDisplayComponent {
  heldKeys = injectHeldKeys()
}
@Component({
  template: `<div>Currently pressed: {{ heldKeys().join(' + ') || 'None' }}</div>`,
})
export class KeyDisplayComponent {
  heldKeys = injectHeldKeys()
}