0.0.3 • Published 8 months ago

svelte-hotkey v0.0.3

Weekly downloads
-
License
-
Repository
github
Last release
8 months ago

svelte-hotkey

An action to add a keyboard shortcut.

Usage

<script>
    import { hotkey } from 'svelte-hotkey'

    let times = 0

    const action = () => {
        times++
    }
</script>

<svelte:window use:hotkey={{metaKey: true, code: 'KeyK', handle:()=>alert('Pressed Cmd+K')}}/>

<p>
    Press <kbd>[Cmd+K]</kbd> for alert
</p>

<button
        on:click={action}
        use:hotkey={{metaKey: true, shiftKey: true, code: 'Digit1'}}
>Press <kbd>[Cmd+Shift+1]</kbd></button>

{#if times}
    <p>Times: {times}</p>
{/if}
0.0.3

8 months ago

0.0.2

8 months ago

0.0.1

8 months ago