type HotkeyCallback<TContext> = (event, context) => void;Defined in: hotkey.types.ts:290
Callback function type for hotkey handlers.
TContext extends HotkeyCallbackContext = HotkeyCallbackContext
KeyboardEvent
The keyboard event that triggered the hotkey
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.
void
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)
}
}