function createHotkey<T>(
hotkey,
callback,
options?): void;Defined in: packages/svelte-hotkeys/src/createHotkey.svelte.ts:63
Svelte function for registering a hotkey on the document: a chord such as 'Mod+S', a sequence such as ['G', 'G'], or an app hotkey from defineAppHotkeys. Pass getters for reactive values. Use createHotkeyAttachment for element-scoped hotkeys.
Chords accept requireReset; sequences accept timeout. A one-step sequence registers as its chord. An app hotkey uses its effective hotkey from HotkeysProvider (including the user's custom hotkey) and its declared meta and options, and registers nothing while unbound.
T extends AppHotkey<string, HotkeyChord | HotkeySequence | null>
MaybeGetter<T>
HotkeyCallback
MaybeGetter<CreateAppHotkeyOptions<T>>
void
<script lang="ts">
createHotkey('Mod+S', () => save())
createHotkey(['G', 'G'], () => scrollToTop(), { timeout: 500 })
createHotkey('Escape', () => close(), () => ({ enabled: isOpen }))
</script>function createHotkey<T>(
hotkey,
callback,
options?): void;Defined in: packages/svelte-hotkeys/src/createHotkey.svelte.ts:68
Svelte function for registering a hotkey on the document: a chord such as 'Mod+S', a sequence such as ['G', 'G'], or an app hotkey from defineAppHotkeys. Pass getters for reactive values. Use createHotkeyAttachment for element-scoped hotkeys.
Chords accept requireReset; sequences accept timeout. A one-step sequence registers as its chord. An app hotkey uses its effective hotkey from HotkeysProvider (including the user's custom hotkey) and its declared meta and options, and registers nothing while unbound.
T extends RegisterableHotkey
MaybeGetter<T>
HotkeyCallback<HotkeyCallbackContextFor<T>>
MaybeGetter<AdapterOptionsFor<T, CreateHotkeyTarget>>
void
<script lang="ts">
createHotkey('Mod+S', () => save())
createHotkey(['G', 'G'], () => scrollToTop(), { timeout: 500 })
createHotkey('Escape', () => close(), () => ({ enabled: isOpen }))
</script>