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

3.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,
}, }} />

Changelog

Package Sidebar

Install

npm i @svelte-put/shortcut

Weekly Downloads

6,000

Version

3.1.0

License

MIT

Unpacked Size

23.2 kB

Total Files

8

Last publish

Collaborators

  • vnphanquang