@svelte-put/shortcut
TypeScript icon, indicating that this package has built-in type declarations

4.1.0 • Public • Published

@svelte-put/shortcut

npm.badge bundlephobia.badge docs.badge

Svelte action use:shortcut - add event listener for keyboard shortcuts

svelte-put

This package is part of the @svelte-put family. For contributing guideline and more, refer to its readme.

Usage & Documentation

See the dedicated documentation page here.

Quick Start

<script lang="ts">
  import { shortcut, type ShortcutEventDetail } from '@svelte-put/shortcut';

  function handleK(detail: ShortcutEventDetail) {
    console.log('attached node:', detail.node);
    console.log('original trigger config:', detail.trigger);
  }
</script>

<svelte:window
  use:shortcut={{
    trigger: {
      key: 'k',
      modifier: ['ctrl', 'meta'],
      callback: handleK,
    },
  }}
/>

Package Sidebar

Install

npm i @svelte-put/shortcut

Weekly Downloads

22,843

Version

4.1.0

License

MIT

Unpacked Size

24 kB

Total Files

9

Last publish

Collaborators

  • vnphanquang