Svelte Hotkeys wraps hotkeys-js
to bring hotkeys to svelte!
<script>
import { hotkeys } from "svelte-hotkeys";
</script>
<!--
We use the action on window so the keybind works anywhere in the app.
You can have the same handler be activated by multiple hotkeys by seperating them with a comma. Here we have ctrl + x and command + x, command is Mac OS's equivilent to control, without the command alternative Mac users won't be able to run the hotkey.
-->
<svelte:window
use:hotkeys={{
keys: 'ctrl+x,command+x',
handler: (event) => console.log(event) }}
/>