bind-keyboard

npm ↗ GitHub ↗

Recipes — practical, copy-pasteable guides.

  • React keyboard shortcuts: the useKeybind hook

    Register a shortcut in one line, no manual useEffect/cleanup, no stale closures, inherently SSR-safe.

  • Keyboard shortcuts in Next.js, SSR-safe

    App Router and Pages Router, without a "window is not defined" crash during server rendering.

  • Building a Cmd/Ctrl+K command palette

    The cross-platform modifier alias, a dedicated scope, and closing on Escape while a search input is focused.

  • Keyboard shortcuts inside a modal (and only there)

    Scoping bindings so background shortcuts can't fire behind an open dialog.

  • Vim and Gmail-style key sequences

    Press g then g — sequences, timeouts, and how ambiguous sequences are resolved.

  • Migrating from Mousetrap or hotkeys-js

    API mapping, what changes, and the one thing (simultaneous multi-key chords) that has no direct equivalent.

← Back to the bind-keyboard demo