caliper uidocs

Shortcut recorder

Free

Press a key combination to record a keyboard shortcut, with conflict warnings.

Installs components/ui/shortcut-recorder.tsxDepends on none beyond ReactMotion none in component source
pnpm dlx shadcn@latest add https://caliperui.site/r/shortcut-recorder.json

Click, 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 #

terminal
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.

example.tsx
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
PropTypeDefault
label *string—
valuestring—
defaultValuestring""
onValueChange((value: string) => void)—
bindingsreadonly ShortcutBinding[][]
resetValuestring—
namestring—
classNamestring—

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.

KeyBehaviour
EscapeCloses or cancels, then returns focus to where it came from.

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.