Shortcut recorder
FreePress a key combination to record a keyboard shortcut, with conflict warnings.
pnpm dlx shadcn@latest add https://caliperui.site/r/shortcut-recorder.jsonClick, then press the keys.
When to use #
Use it for
- Settings where people choose their own shortcuts.
- You need to warn about shortcuts already in use.
Skip it when
- The shortcut is fixed; show it as text.
Installation #
pnpm dlx shadcn@latest add https://caliperui.site/r/shortcut-recorder.json
Adds its 3 files to components/ui/, each with its own stylesheet, and installs their packages. No account needed. The first part also adds Caliper UI’s tokens; import them once as in Installation.
Usage #
This is the code behind the preview above. It is built from ShortcutRecorder and formatShortcut.
import { useState } from "react" import { ShortcutRecorder } from "@/components/ui/shortcut-recorder" export function SearchShortcut() { const [shortcut, setShortcut] = useState("mod+k"); return ( <div className="w-full max-w-xs"> <ShortcutRecorder label="Open search" value={shortcut} onValueChange={setShortcut} resetValue="mod+k" /> </div> ); }
API reference #
ShortcutRecorder
component
formatShortcut
component
No props of its own; it accepts the native props of its root element.
Accessibility #
It exposes status semantics, with aria-pressed and aria-label kept in step with state. Changes that matter are announced through a live region.
Motion #
It declares no animation in its component source. Any transition comes from its stylesheet, which uses the duration tokens that collapse to instant under prefers-reduced-motion.