Hotkeys Docs
Getting Started
AI/LLM: This documentation page is available in plain markdown format at/hotkeys/latest/docs/framework/octane/reference/functions/defineHotkey.md
defineHotkey
ts
function defineHotkey<T>(definition): Readonly<UseHotkeyDefinition>;Defined in: useHotkeys.ts:40
Checks one hotkey for useHotkeys as useHotkey checks its arguments, and returns it unchanged. In an array, a hotkey object is checked only when it is written inline, and it takes the options of both kinds. Here the hotkey can be a variable, a key no hotkey object has is a type error, and the callback context and the options follow the kind of the hotkey.
Type Parameters#
T#
T extends AdapterHotkeyInput
Parameters#
definition#
AdapterHotkeyDefinitionInput<T, UseHotkeyTarget>
Returns#
Readonly<UseHotkeyDefinition>
Example#
tsx
const play = defineHotkey({
hotkey: { default: 'Space', alternates: ['K'] },
callback: () => togglePlay(),
options: { requireReset: true },
})
useHotkeys([play])