shadcn.io is not affiliated with official shadcn/ui
Esc to cancel, Tab to move, Enter to confirm: three keys almost every interface responds to. This React example shows them as three Kbd caps in a row with a small gap, for keyboard help in dialogs, forms and onboarding.
Preview
Installation
FAQ
Which special keys should I document?
The ones whose behavior isn't obvious in your app: Esc if it closes panels or cancels edits, Enter if it submits or confirms, Tab if focus moves through a custom widget. Standard form behavior rarely needs a hint.
Should I show them alone or with modifiers?
Alone when the key does the job by itself, like Esc to close. Combined when it needs a modifier, like Shift Tab to go back or ⌘ Enter to send a message in a multi-line field.
When should a form show Esc, Tab or Enter?
When the form does something unexpected with them: Enter adds a tag instead of submitting, ⌘ Enter submits from a text area, Esc discards changes. Put the hint next to the field or button it affects.
Should dialogs show that Esc closes them?
The Dialog closes on Esc already, and most people expect it, so a hint is optional. It helps in focused tools like a command palette, where Esc is part of the flow.
Related
- Modifier Keys KbdThe Shift, Ctrl and Alt modifier keys in
- Editing Keys KbdThe Home, End, PgUp and PgDn editing keys
- F1 Help Key KbdA single F1 key, the usual shortcut for
- Standard DialogA share dialog with a read-only link, a
- F12 DevTools Key KbdA single F12 key, the shortcut that opens
- Function Keys Row KbdThe full F1 to F12 function key row