Skip to content
RivetUI

Keyboard Shortcut

Displays platform-aware key combinations and registers matching keyboard listeners.

@rivetui/keyboard-shortcut

Preview

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

Registry

Installation

Add the component source and its declared dependencies with the shadcn CLI.

Install component
bunx --bun shadcn@latest add @rivetui/keyboard-shortcut
Inspect registry item

Public interface

API reference

Component-specific props are listed here. Native element and Base UI props continue to pass through.

KeyboardShortcut

PropTypeDefault
keysreadonly [KeyboardShortcutKey, ...KeyboardShortcutKey[]]—
size"sm" | "md""md"
platform"auto" | "mac" | "windows" | "linux""auto"
aria-labelstringgenerated

KeyboardShortcutScript

Render KeyboardShortcutScript once in the root layout's <head> to resolve automatic platform labels before the first paint.

PropTypeDefault
noncestring—

useKeyboardShortcut

ParameterTypeDefault
keysKeyboardShortcutKeysrequired
onTrigger(event: KeyboardEvent) => voidrequired
optionsUseKeyboardShortcutOptions{}

UseKeyboardShortcutOptions

OptionTypeDefault
enabledbooleantrue
preventDefaultbooleantrue
allowInEditablebooleanfalse
allowRepeatbooleanfalse
platform"auto" | "mac" | "windows" | "linux""auto"
Rivet UI / Keyboard ShortcutComponents engineered, not decorated.