Skip to content
Design System
GitHub

useHotkeys

v0.16.0Beta

Keyboard shortcuts as a map of keys to handlers ({ "1": yes, "mod+z": undo, "?": help }), quiet while someone types in a field, with the key being pressed for Kbd.

0 yes · 0 no

Use hotkeys review

Install
npx shadcn add @syncrobotic/use-hotkeys

Overview

When to use

  • A review or labelling queue answered by keyboard.
  • A tool's global shortcuts, like mod+k for search.

Use something else

  • Keys inside one widget (arrows in a list): the widget's own onKeyDown, or the Radix component that has them.

Usage rules

  • Single keys only where people work through a queue by keyboard (1 Yes, 2 No, ? help); everywhere else a shortcut takes a modifier (mod+k).
  • Keys are ignored while someone types in a field, unless a binding sets allowInInput (Escape, mod+s).
  • Turn it off with enabled: false while a dialog is open, so the dialog's own keys win.
  • Show the keys on screen (Kbd) and in a ? dialog: a shortcut nobody can find does not exist.

Changelog

  • 0.16.02026-11-19First release: useHotkeys(map, { enabled }) with mod/ctrl/meta/alt/shift combos, keys ignored in text fields unless allowInInput, no repeats unless asked, and pressed for <Kbd pressed>.

How to upgrade