Skip to content

Hotkey

Parses hotkey strings, prints platform-aware key labels and spoken names, and matches keyboard events.

Write a shortcut once as text (mod+s, shift+a, alt+left) and use it twice: matchesHotkey(event, hotkey) tells a key handler whether that shortcut was pressed, and formatHotkey, keyLabel and spokenKey print it for the platform. mod is Command on Apple platforms and Control elsewhere; useIsApple() says which, and is true on the server. The library binds nothing: you choose where to listen. Listen on the part of the page a shortcut belongs to, and keep clear of the keys the browser and assistive technology use.

Key labels for this platform

Save
Command S
Send
Command Enter
Assign to me
Shift A
Go back
Option Left arrow
Close the panel
Escape

Submit with a shortcut

    Shortcuts for a focused row

    Write the migration guide

    Focus a button in the row, then press a shortcut.

    Installation

    npx shadcn@latest add @khaeli/hotkey

    Installs with

    Nothing else. This item needs no other Registry item and no npm package.

    Keyboard

    ⌘ EnterCtrl Enter
    In Submit with a shortcut, posts the comment while the field has focus. Enter alone adds a line.
    Shift A
    In Shortcuts for a focused row, assigns the task to you, or unassigns it, while focus is in the row.
    E
    In Shortcuts for a focused row, archives or restores the task while focus is in the row.

    Accessible name

    • A shortcut is never the only way: every one here has a button that does the same thing.
    • Keycaps are symbols. Hide them with aria-hidden and give the words from spokenKey to assistive technology, or name the keys in aria-keyshortcuts on the control they belong to.

    Registry JSON

    The item as the shadcn CLI reads it, with every file it ships: https://ui.khaeli.com/r/hotkey.json