Keyboard Shortcut
Displays platform-aware key combinations and registers matching keyboard listeners.
@rivetui/keyboard-shortcutPreview
Explore each composition interactively, then open its code in the same context.
Shortcut labels
Render typed key combinations anywhere an action needs a compact keyboard hint.
Note
mod resolves to Command on macOS and Control on Windows or Linux unless platform is set explicitly.
Open command bar
Open project
Run build task
Platforms and keys
Override the platform for documentation or show compact navigation keys without separate examples.
macOSWindows
Global listener
Use the matching hook when the displayed shortcut should also trigger an action.
Note
Editable controls are ignored by default so global shortcuts do not interrupt typing.
Press to test the global listener.
WaitingRegistry
Installation
Add the component source and its declared dependencies with the shadcn CLI.
Install component
bunx --bun shadcn@latest add @rivetui/keyboard-shortcutPublic interface
API reference
Component-specific props are listed here. Native element and Base UI props continue to pass through.
KeyboardShortcut
| Prop | Type | Default |
|---|---|---|
keys | readonly [KeyboardShortcutKey, ...KeyboardShortcutKey[]] | — |
size | "sm" | "md" | "md" |
platform | "auto" | "mac" | "windows" | "linux" | "auto" |
aria-label | string | generated |
KeyboardShortcutScript
Render KeyboardShortcutScript once in the root layout's <head> to resolve automatic platform labels before the first paint.
| Prop | Type | Default |
|---|---|---|
nonce | string | — |
useKeyboardShortcut
| Parameter | Type | Default |
|---|---|---|
keys | KeyboardShortcutKeys | required |
onTrigger | (event: KeyboardEvent) => void | required |
options | UseKeyboardShortcutOptions | {} |
UseKeyboardShortcutOptions
| Option | Type | Default |
|---|---|---|
enabled | boolean | true |
preventDefault | boolean | true |
allowInEditable | boolean | false |
allowRepeat | boolean | false |
platform | "auto" | "mac" | "windows" | "linux" | "auto" |