0.1.1 • Published 3 years ago
svelte-hotkeys v0.1.1
Docs coming soon!
Meanwhile, basic usage:
import { hotkeys } from "svelte-hotkeys";
Later in svelte component
<svelte:window use:hotkeys={{ keys: 'ctrl+x', handler: (ev) => console.log(ev) }} />
This binds hotkeys
to the window
, as in hitting the key anywhere will trigger the handler
if you wanna make hotkeys specific to a specific element, as in, if a div
is in focus and user hits the key combo, the handler should be triggered. This can be done by applying this action on a focusable div
<div tabindex={0} use:hotkeys={{ keys: 'ctrl+x', handler: (ev) => console.log(ev) }} />