Hotkeys
The @nizivo/react/hotkeys entry.
Import
import { registerHotkey, toTinykeys, useHotkey, useHotkeys } from '@nizivo/react/hotkeys';Exports
Hotkeytypeimport type { Hotkey } from '@nizivo/react/hotkeys'A shortcut and what it does.
Name Type Default Description allowInInputsbooleanfalseAlso while focus is in a text field.
descriptionrequiredstring– What it does, for a list of shortcuts: "Open the command menu".
idrequiredstring– Unique in the page; registering an
idagain replaces the first.keysrequiredstring– "mod+k","shift+?","mod+shift+d", asKbd keystakes them.runrequired(event: KeyboardEvent) => void– HotkeyInfotypeimport type { HotkeyInfo } from '@nizivo/react/hotkeys'A registered shortcut as
useHotkeyslists it.Name Type Default Description descriptionrequiredstring– idrequiredstring– keysrequiredstring– registerHotkeyfunctionimport { registerHotkey } from '@nizivo/react/hotkeys'Registers a shortcut; returns the function that removes it.
function registerHotkey(hotkey: Hotkey): () => voidtoTinykeysfunctionimport { toTinykeys } from '@nizivo/react/hotkeys'"mod+shift+k"→ tinykeys'"$mod+Shift+k".function toTinykeys(keys: string): stringuseHotkeyhookimport { useHotkey } from '@nizivo/react/hotkeys'Registers a shortcut while the component is mounted (and not hidden in an Activity).
runmay change on every render; the latest one runs.function useHotkey(hotkey: Hotkey): voiduseHotkeyshookimport { useHotkeys } from '@nizivo/react/hotkeys'Every registered shortcut, in registration order; none on the server.
function useHotkeys(): readonly HotkeyInfo[]