Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Kbd examples · Shortcut

Complex Shortcut Kbd for React

A three-key Ctrl Shift P shortcut in one key group.

Framework
UI library

Two-key shortcuts run out fast, so less common commands get a second modifier. This React example shows Ctrl, Shift and P in one KbdGroup, the shortcut that opens the command palette in code editors such as VS Code. The group spaces all three caps evenly so they read as one chord.

Preview

Preview width
CtrlShiftP

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

FAQ

When should I use a three-key shortcut?

For commands that are used often enough to need a shortcut but not as often as copy or save, and for variants of a two-key shortcut: Ctrl Shift Z to redo next to Ctrl Z to undo. Keep the most frequent commands on two keys.

In what order should modifiers be shown?

Follow the platform: macOS lists ⌃ Control, ⌥ Option, ⇧ Shift, ⌘ Command, in that order, and Windows puts Ctrl first, as in Ctrl Shift P. Then the main key last.

How do I detect Ctrl Shift P?

In a keydown listener, check event.ctrlKey (or event.metaKey on Mac) and event.shiftKey, and compare the key. With Shift held, event.key may be an uppercase P, so compare it case-insensitively or use event.code, which is KeyP.

Are three-key shortcuts comfortable to press?

Two modifiers on the left plus a letter is manageable for one hand when the letter is near them. Shortcuts that stretch to the far side of the keyboard are hard to press and harder for people with limited mobility.

What are the alternatives to three-key shortcuts?

A command palette, where people type the command's name, or a sequence like Ctrl K then B, which uses two easy presses instead of one hard one. The Key Sequence with Then example shows how to display it.

How do I make three-key shortcuts accessible?

Make every command reachable without the shortcut, from a menu or a palette. Operating systems offer sticky keys for people who can't hold several keys, and letting people remap shortcuts helps too.