Key
Every button, and every link that acts like one: a cap on a skirt that drops below the plate when pressed.
Kit part · Buttons
The key to press, drawn as the key: a small cap on a skirt with a dish worked into its top. Shortcuts come as combos and follow the platform, so ⌘ K on a Mac is Ctrl K elsewhere.
Press Esc to close it, or Tab to move on.
Both finishes, side by side. Hover, pressed and focus are forced with .is-hover, .is-down and .is-focus; checked and disabled are real.
Aluminium
| Part | Rest | Held down |
|---|---|---|
| 18 px | K | K |
| 22 px | K | K |
| 30 px | K | K |
| Wide | Space | Space |
Graphite
| Part | Rest | Held down |
|---|---|---|
| 18 px | K | K |
| 22 px | K | K |
| 30 px | K | K |
| Wide | Space | Space |
| Name | Kind | Values | What it does |
|---|---|---|---|
| .tui-kbd | class | on <kbd> | A cap: 22px tall, a skirt below, a dish inside. Printed in the second ink, in the sans, never the mono. |
| --sm · --lg · --wide | class | 18 · 30 px · 3× wide | Sizes; wide is for Space and other long keys. |
| .tui-kbd-combo | class | around several caps | A shortcut: caps 3px apart. |
| .tui-kbd-combo__plus | class | aria-hidden | A printed + between caps, for teaching a combo. |
| .tui-kbd__name | class | inside a symbol cap | The spoken name: “Command” for ⌘. Not drawn. |
| data-kbd · data-kbd-size · data-kbd-plus | attribute | "Mod+K" · "sm" · — | On any element: kit.mjs fills it with the caps for the visitor’s platform. |
| Mod | key name | ⌘ · Ctrl | The platform’s main modifier. Others: Ctrl, Alt, Shift, Enter, Esc, Tab, Space, Backspace, Delete, Up, Down, Left, Right. |
| data-kbd-live | attribute | on a container | The caps inside sink while their real keys are held. |
| kbdLabels(shortcut, { mac }) · kbdHTML(shortcut, options) | function | kit.mjs | The parts of a shortcut, and its markup. Pure: the platform is an argument. |
| wireKbd(root) | function | kit.mjs | Fill every [data-kbd] under root. Runs once on load; call it for markup you add later. |
<!-- One cap per key -->
<span class="tui-kbd-combo"><kbd class="tui-kbd">Ctrl</kbd><kbd class="tui-kbd">K</kbd></span>
<!-- Or let the script pick the keys for the platform: ⌘ K on a Mac, Ctrl K elsewhere -->
<span data-kbd="Mod+K"></span>
<span data-kbd="Mod+Shift+P" data-kbd-size="sm" data-kbd-plus></span>
<!-- Inside a sentence -->
<p>Press <kbd class="tui-kbd tui-kbd--sm">Esc</kbd> to close it.</p>
<!-- A symbol names itself for a screen reader -->
<kbd class="tui-kbd"><span aria-hidden="true">⌘</span><span class="tui-kbd__name">Command</span></kbd>import { kbdLabels, kbdHTML, wireKbd } from '/kit/kit.mjs';
kbdLabels('Mod+Shift+K', { mac: true });
// [{ text: '⌘', name: 'Command', key: 'meta' }, { text: '⇧', … }, { text: 'K', … }]
el.innerHTML = kbdHTML('Mod+K', { size: 'sm', plus: true });
wireKbd(container); // fills every [data-kbd] under itNeeds kit.css and kit.mjs. How to install the kit.
<kbd> is text, not a control: it is not focusable and it does nothing. To press something, use a key.A cap is the key’s own anatomy scaled down: a face gradient with the catch-light along its top edge, a skirt of the darker metal one or two pixels below, and a shadow under that. Its dish is a second, lower face inset 2px (concentric with the cap, so its corner is the cap’s less the rim) with a soft shadow along its upper wall. Held, the cap drops by the height of its skirt and takes the pressed light, exactly as a key does. kbd.mjs holds a small table of key names, each with its Mac glyph, its printed word elsewhere and what to say aloud; the rest is arithmetic and string-building, exported for tests.
Show the keys, not the letters: a cap for each key, right for the platform, named for a screen reader.
4 rules in this file, with the foundations they rest on and the anti-patterns that break them. Full rules ship in the brain with the Pass.
Every button, and every link that acts like one: a cap on a skirt that drops below the plate when pressed.
Every action and page behind one key: a modal plate whose entry line is a lit display, with the results printed below and the chosen one pressed in.
A card of actions and options that slides out from under its key. The key stays down while the card is out; an option that is on lights its lamp.