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

HotkeyCallback

ts
type HotkeyCallback<TContext> = (event, context) => void;
type HotkeyCallback<TContext> = (event, context) => void;

Defined in: hotkey.types.ts:290

Callback function type for hotkey handlers.

Type Parameters

TContext

TContext extends HotkeyCallbackContext = HotkeyCallbackContext

Parameters

event

KeyboardEvent

The keyboard event that triggered the hotkey

context

TContext

The registered hotkey and its parsed form. APIs that take one hotkey narrow it to chord or sequence context from the hotkey you pass.

Returns

void

Example

ts
const handler: HotkeyCallback = (event, context) => {
  if (context.kind === 'chord') {
    console.log(context.hotkey, context.parsedChord.modifiers)
  } else {
    console.log(context.hotkey.join(' '), context.parsedSequence.length)
  }
}
const handler: HotkeyCallback = (event, context) => {
  if (context.kind === 'chord') {
    console.log(context.hotkey, context.parsedChord.modifiers)
  } else {
    console.log(context.hotkey.join(' '), context.parsedSequence.length)
  }
}