Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Kbd examples · Function Keys

Special Keys Kbd for React

The Esc, Tab and Enter keys in a row.

Framework
UI library

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

Preview width
EscTabEnter

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

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.

Are Esc, Tab and Enter accessible?

They're the core of keyboard navigation, so keep their standard behavior: Tab moves focus forward, Enter activates, Esc dismisses. Changing them breaks keyboard and screen reader use.

How do I set special keys apart from letter keys?

Their names already make the caps wider. A return or tab symbol before the name adds a visual cue, as the Unicode Symbols and Enter with Icon examples show.