shukar1 / svelte-shortcut-manager

handle global & contexted shortcuts neatly, with an optional supportive UI

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Svelte Key Sequence Capture

npm i svelte-key-sequence-capturer

Types

type KeyCode = {
    [prop: string]: {
        code: string | string[];
        symbol: string;            
    }
}

interface Shortcut {
    title: string | () => string;
    sequence: KeyCode[];
    fn: () => void;
    escaped?: () => boolean;
}

API

Inputs:

permanents: Shortcut[];
helper: boolean // show window
strict: boolean // show window only if a key is pressed

A pre-made Keys lib is also exported

Future

  • Usage based attaching/detaching of scoped shortcuts

About

handle global & contexted shortcuts neatly, with an optional supportive UI


Languages

Language:Svelte 51.3%Language:TypeScript 22.0%Language:JavaScript 16.1%Language:CSS 10.6%