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

RawHotkeyChord

ts
type RawHotkeyChord = 
  | object & RawModifiers
  | object & RawModifiers;
type RawHotkeyChord = 
  | object & RawModifiers
  | object & RawModifiers;

Defined in: hotkey.types.ts:195

A chord written as an object instead of a string, for building chords from data. Set key for a logical key or code for a physical one, and set a boolean for each modifier. Omitted modifiers default to false.

The mod modifier is platform-adaptive: Command on macOS, Control on Windows/Linux. Sequence steps can be objects too: [{ key: 'K', mod: true }, 'C'].

Example

ts
useHotkey({ key: 'S', mod: true }, handler)             // Mod+S (cross-platform)
useHotkey({ key: 'S', ctrl: true }, handler)            // Control+S
useHotkey({ key: 'Escape' }, handler)                   // Escape (no modifiers)
useHotkey({ key: 'A', shift: true, meta: true }, handler) // Shift+Meta+A
useHotkey({ key: 'S', mod: true, shift: true }, handler)  // Mod+Shift+S
useHotkey({ code: 'KeyW', mod: true }, handler)           // Physical Mod+KeyW
useHotkey({ code: 'NumpadAdd', mod: true }, handler)      // Physical numpad plus
useHotkey({ key: 'S', mod: true }, handler)             // Mod+S (cross-platform)
useHotkey({ key: 'S', ctrl: true }, handler)            // Control+S
useHotkey({ key: 'Escape' }, handler)                   // Escape (no modifiers)
useHotkey({ key: 'A', shift: true, meta: true }, handler) // Shift+Meta+A
useHotkey({ key: 'S', mod: true, shift: true }, handler)  // Mod+Shift+S
useHotkey({ code: 'KeyW', mod: true }, handler)           // Physical Mod+KeyW
useHotkey({ code: 'NumpadAdd', mod: true }, handler)      // Physical numpad plus