Skip to content
ShellKeyboard shortcutsMenu

Keyboard shortcuts

A dialog with every shortcut grouped by area, a filter and platform-aware keys, plus a ShortcutKeys renderer for tooltips and menus.

Every shortcut grouped by area, with a filter and platform-aware keys.

Installation

$ pnpm dlx shadcn@latest add https://chatcn.dev/r/keyboard-shortcuts.json

Usage

tsx
import { defaultShortcuts, KeyboardShortcuts, ShortcutKeys } from "@/components/ui/chatcn/keyboard-shortcuts"

// Opens on Cmd+/ or Ctrl+/ by itself.
<KeyboardShortcuts
  shortcuts={[
    ...defaultShortcuts,
    { id: "run", label: "Run the agent", keys: "mod+enter", group: "Agent" },
  ]}
/>

// The same keys anywhere else.
<ShortcutKeys keys="mod+shift+o" />

Keys are hotkey strings from useChatcnHotkeys: mod renders as ⌘ on a Mac and Ctrl elsewhere, and an array lists alternatives with or between them. Spell the comma key comma, since a comma separates alternatives in one string.

Props

PropTypeNotes
shortcutsShortcut[]id, label, keys, group, when. Default defaultShortcuts
groupsstring[]Group order
open, defaultOpen, onOpenChangeControlled or uncontrolled
hotkeystring | nullDefault mod+/
filterbooleanShow the filter field. Default true
title, descriptionReactNodeDialog heading
applebooleanForce Mac or PC key labels

Keyboard

KeyAction
Cmd+/, Ctrl+/Open or close
TypingFilters by label and area
EscClose and return focus

Accessibility

  • Each area is a labelled section with a description list: the action is the term, the keys are the definition.
  • The filter gets focus on open, so typing narrows the list at once.
  • Key symbols come from the platform, so a Windows user never reads ⌘.

Motion

  • Opened with the shortcut or closed with Escape, the dialog appears and leaves instantly.
  • Opened with a pointer, it scales from 0.96 and fades in over 220 ms, and leaves over 160 ms.