<!--
  GENERATED FILE - do not edit by hand.
  Source of truth: src/components/mds-keyboard-key/ in the magma monorepo (usage/*.md and the
  component's JSDoc). Regenerated on every stencil build (scripts/component-docs.ts).
-->

# mds-keyboard-key

> `@maggioli-design-system/magma` 2.15.0. Shadow DOM: style it only through the public CSS custom properties and the parts below.

The `<mds-keyboard-key>` web component renders a single physical-looking keycap inside a [`<mds-keyboard>`](../mds-keyboard/AGENTS.md) parent, supplying the visual unit for one key of a shortcut combination (e.g. the `Ctrl` or `C` in `Ctrl + C`). It has no direct HTML equivalent - it is a presentational glyph whose meaning and test behavior are orchestrated by the parent.

#### Semantic Behavior

- **Compound child only**: It must be a direct slot child of `<mds-keyboard>`; it is not used standalone or mixed with other element types, since the parent reads its `name` to build the key combination and inserts `+` separators between keys.
- **Glyph resolution from `name`**: When `name` maps to a known icon (arrows, command, shift, enter, tab, space, etc.) it renders that icon; otherwise it renders the key's alias from the dictionary (e.g. `Ctrl`, `Esc`). The `space` key is drawn at least twice as wide as the others.
- **Keyboard-side indicator**: For the side-specific names (`shiftleft`, `controlright`, ...), it appends an `l` / `r` label.
- **Pressed state is parent-driven**: The `pressed` prop is toggled by `<mds-keyboard>` during a verification test as the user types; it is not meant to be set manually for presentational use.
- **Localized title**: The host receives a localized `title` describing the key (el/en/es/it).
- **No interactive role**: The keycap is purely visual - it exposes no role, focus handling, or emitted events of its own.

#### Properties & Visual Configurations

This child has essentially no presentational configuration; it does not use the shared `variant` / `tone` ladders from [`agents/variants.md`](../../../../agents/variants.md).

- **`name`** is the only meaningful authoring prop: set it to the canonical key code (one value from the keyboard key dictionary, e.g. `control`, `arrowup`, `c`) for the key this cap represents. It selects the displayed glyph or alias and feeds the parent's combination matching.
- **`pressed`** is a state hook, not an authoring choice - let the parent set it during a test. Leave it unset for a static shortcut display.

## Read next

- [`examples.md`](examples.md) - correct usage, from the most common case
- [`mistakes.md`](mistakes.md) - the wrong forms, each with the right one
- [Storybook](https://magma-design-system.github.io/magma/storybook/?path=/docs/ui-keyboard-key--docs) - the live examples, in the published Storybook of `main`
- [`conventions.md`](../../../../agents/conventions.md), [`variants.md`](../../../../agents/variants.md), [`mistakes.md`](../../../../agents/mistakes.md) - the rules shared by every component

## Props

| Prop | Attribute | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `name` | `name` | `"0" \| "1" \| "2" \| "3" \| "4" \| "5" \| "6" \| "7" \| "8" \| "9" \| "a" \| "alt" \| "altleft" \| "altright" \| "arrowdown" \| "arrowleft" \| "arrowright" \| "arrowup" \| "b" \| "backspace" \| "c" \| "capslock" \| "command" \| "commandleft" \| "commandright" \| "control" \| "controlleft" \| "controlright" \| "d" \| "delete" \| "e" \| "end" \| "enter" \| "escape" \| "f" \| "f1" \| "f10" \| "f11" \| "f12" \| "f2" \| "f3" \| "f4" \| "f5" \| "f6" \| "f7" \| "f8" \| "f9" \| "g" \| "h" \| "home" \| "i" \| "j" \| "k" \| "l" \| "m" \| "n" \| "o" \| "option" \| "optionleft" \| "optionright" \| "p" \| "pagedown" \| "pageup" \| "q" \| "r" \| "s" \| "shift" \| "shiftleft" \| "shiftright" \| "space" \| "t" \| "tab" \| "u" \| "v" \| "w" \| "windows" \| "windowsleft" \| "windowsright" \| "x" \| "y" \| "z"` | - | Sets the code of the keyboard key for combination tests if `try` attribute is set from `mds-keyboard` parent component |
| `pressed` | `pressed` | `boolean \| undefined` | - | Sets if the key is pressed or not |

## CSS custom properties

| Property | Description |
| --- | --- |
| `--mds-keyboard-key-padding` | Set the padding of the keyboard key. |

Only these are public. Its other 5 are internal: they may change in any release, do not set them.

## Dependencies

Uses: `mds-icon`, `mds-text`.
