# Kbd

A key or a combo in one chip, drawn for the visitor's platform and spelled out for a screen reader.

Live variants: https://design.arcadia.is/components/kbd

```tsx
import {
  Kbd, KeyLegend, shortcutKeys, spokenKeys, isGlyphShortcut, ariaKeyShortcuts,
  shortcut,
} from "@arcadia/ui";
```

- In a menu row
- In a tooltip
- In a sentence
- In a field

## Accessibility

`Kbd` renders `<kbd>`, read in place as part of its sentence. Its glyphs are hidden from a screen reader, which reads ⌘ and ⇧ unevenly, and words it hides from sight say the keys in the platform's own names instead: "Command Shift A" on a Mac, "Control Shift A" elsewhere (`spokenKeys`).

Inside a control, the shortcut belongs on the control as `aria-keyshortcuts` (`"⌘⇧K"` becomes `Meta+Shift+K`) and the chip is `aria-hidden`, so the name stays the label: Button `hint`, MenuItem `shortcut`, ListRow `shortcut` and Tooltip `shortcut` do both for you.

A chip is never focusable and has no keys of its own: showing a shortcut doesn't bind it. Use the plain variant inside a field. In forced colours a keycap's ground gives way to an edge in the system's ink. Its height is a least height, so a person's own text spacing grows it instead of clipping the key.

## API reference

### Kbd

- `keys` (`string | readonly string[]`): One key or a combo, drawn in one chip: `"mod+shift+k"`, `"⌘⇧K"`, `["⌘", "K"]` (see `shortcutKeys`).
- `size` (`"sm" | "md"`, default `"sm"`): `sm` a chip 20 tall, in a menu, a tooltip, a row or a sentence; `md` 24 tall, in a list of shortcuts.
- `variant` (`"key" | "plain"`, default `"key"`): `key`: the keys in one chip. `plain`: one run of text, a hint inside a control (a field's end).
- `children` (`string`): The keys as text, read as `keys` is: `<Kbd>Esc</Kbd>`.

Rest props go to `<kbd>` props and `render`.

### KeyLegend

- `hints` (`readonly KeyHint[]`, required)

Rest props go to `<div>` props and `render`.
