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.
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
Installation
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.
Related
- Command Palette Shortcut KbdThe ⌘K shortcut that opens a command
- Copy Shortcut KbdThe Ctrl C copy shortcut as a key group
- Save Shortcut KbdThe ⌘S save shortcut as a key group
- Key Sequence with Then KbdA Ctrl K chord, the word then, and a B
- Modifier Keys KbdThe Shift, Ctrl and Alt modifier keys in
- Paste Shortcut KbdThe Ctrl V paste shortcut as a key group