shadcn.io is not affiliated with official shadcn/ui
Copy is the shortcut nearly everyone knows. This React example shows it as Ctrl and C in a KbdGroup, which spaces the two caps evenly and marks them as one shortcut. Use it in context menus, copy buttons and help pages, and show ⌘C instead to Mac users.
Preview
Installation
FAQ
Why is Ctrl C the copy shortcut?
Apple's Lisa and Macintosh put cut, copy and paste on X, C and V, next to each other at the bottom left of the keyboard, where one hand reaches them with the modifier. Windows adopted the same letters with Ctrl, and they became the standard.
Is it Ctrl C everywhere or ⌘C on Mac?
Ctrl C on Windows, Linux and ChromeOS; ⌘C on macOS. Show the one that matches the user's platform, as the Platform-Aware Shortcut example does.
How do I customize what Ctrl C copies?
Listen to the copy event and set the data with event.clipboardData.setData before calling preventDefault. To copy from a button instead, call navigator.clipboard.writeText. Both are browser APIs and work the same in every framework.
Should a custom copy work everywhere or only in some places?
Only where there's something special to copy, such as a selected row in a data grid. Never take over copy in text fields: people expect it to copy their selection.
Related
- Paste Shortcut KbdThe Ctrl V paste shortcut as a key group
- Save Shortcut KbdThe ⌘S save shortcut as a key group
- Complex Shortcut KbdA three-key Ctrl Shift P shortcut in one
- Command Palette Shortcut KbdThe ⌘K shortcut that opens a command
- Arrow Keys Cross Pattern KbdFour arrow keys in the inverted T of a
- Arrow Keys Horizontal KbdLeft and right arrow keys grouped side by