KBD
How the KBD works with a keyboard and assistive tech, and where it stands against WCAG 2.2 AA.
Kbd renders the native <kbd> element, so the key is marked up as keyboard input even without styles. It is not interactive. What it does not do on its own is say symbols aloud: ⌘ and arrows need words for screen readers.
Keyboard#
Passes over the key cap: it is text, not a control.
Semantics#
<kbd>One element per key. Kbd Group places keys side by side with a "+" between them, not nested.
Alwaysaria-labelSet to "left arrow" and so on. On a <kbd>, which has no role, many screen readers ignore aria-label.
Arrow onlyaria-hiddenThe chevron SVG is decorative.
Arrow glyphvisually hidden textNot built in. Add "Command" beside ⌘ so it isn't read as "place of interest" or skipped.
SymbolsColour contrast#
Every variant and state has to meet WCAG 2.2 Level AA. Measure the colours as they land on screen: a translucent hover or press wash over whatever sits behind it.
Label · Flat, Raised
Satoshi Medium 14 in #6d6d6d on the white cap measures 5.17:1. Group labels match; the "+" separator in #8f8f8f is 3.23:1.
WCAG 1.4.3 Contrast (Minimum) ↗Key edge · Flat, Raised
The cap's stroke and shadow are decoration, not a control's boundary.
WCAG 1.4.11 Non-text Contrast ↗Motion#
- Kbd does not animate.
Checklist#
Give every symbol a readable name in visually hidden text: Command, Shift, Option, Up arrow.
Write shortcuts for the platform: ⌘ on Mac, Ctrl elsewhere.
Make sure the shortcut works. A key cap describes a shortcut; it does not register one.
The "+" separator is about 3.2:1. It is a symbol between keys, but darken it if it is the only thing joining them.
