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

createMultiHotkeyChordHandler

ts
function createMultiHotkeyChordHandler(handlers, options?): (event) => void;
function createMultiHotkeyChordHandler(handlers, options?): (event) => void;

Defined in: match.ts:145

Creates a handler that matches several chords.

Parameters

handlers

MultiHotkeyChordHandler

A map of chord strings to their handlers

options?

CreateHotkeyChordHandlerOptions = {}

Options for matching and handling

Returns

A function that can be used as an event handler

(event) => void

Example

ts
const handler = createMultiHotkeyChordHandler({
  'Mod+S': (event, { hotkey }) => handleSave(),
  'Mod+Z': (event, { hotkey }) => handleUndo(),
  'Mod+Shift+Z': (event, { hotkey }) => handleRedo(),
})

document.addEventListener('keydown', handler)
const handler = createMultiHotkeyChordHandler({
  'Mod+S': (event, { hotkey }) => handleSave(),
  'Mod+Z': (event, { hotkey }) => handleUndo(),
  'Mod+Shift+Z': (event, { hotkey }) => handleRedo(),
})

document.addEventListener('keydown', handler)