<!--
  GENERATED FILE - do not edit by hand.
  Source of truth: src/components/mds-keyboard-key/usage/ in the magma monorepo.
-->

# mds-keyboard-key - mistakes

> The API of this component: [`AGENTS.md`](AGENTS.md).

Common incorrect uses of `<mds-keyboard-key>`. Each entry pairs the wrong form with the right one and a one-line reason. System-wide rules (boolean-as-string, shadow piercing, Tailwind color utilities, raw native event listening) live in [`agents/mistakes.md`](../../../../agents/mistakes.md) - they apply here too but are not repeated.

#### Do Not Use `<mds-keyboard-key>` Outside `<mds-keyboard>`

The key is a compound child component and must be a direct slot child of [`<mds-keyboard>`](../mds-keyboard/AGENTS.md). Used standalone it renders visually but has no separator wiring, no test capability, and violates the compound component contract.

```html
<!-- INCORRECT -->
<mds-keyboard-key name="control"></mds-keyboard-key>
<span>+</span>
<mds-keyboard-key name="c"></mds-keyboard-key>

<!-- CORRECT -->
<mds-keyboard>
  <mds-keyboard-key name="control"></mds-keyboard-key>
  <mds-keyboard-key name="c"></mds-keyboard-key>
</mds-keyboard>
```

#### Do Not Add `+` Separators Manually

The parent `<mds-keyboard>` inserts `+` separators between child keys automatically. Adding them manually results in duplicate or misaligned separators.

```html
<!-- INCORRECT -->
<mds-keyboard>
  <mds-keyboard-key name="command"></mds-keyboard-key>
  <span>+</span>
  <mds-keyboard-key name="v"></mds-keyboard-key>
</mds-keyboard>

<!-- CORRECT -->
<mds-keyboard>
  <mds-keyboard-key name="command"></mds-keyboard-key>
  <mds-keyboard-key name="v"></mds-keyboard-key>
</mds-keyboard>
```

#### Do Not Set `pressed` Manually When `try` Is Active

When `<mds-keyboard try>` is enabled, the parent owns `pressed` and sets it as the user types. Setting it manually conflicts with the parent state machine and produces incorrect visual feedback.

```html
<!-- INCORRECT -->
<mds-keyboard try>
  <mds-keyboard-key name="control" pressed></mds-keyboard-key>
  <mds-keyboard-key name="z"></mds-keyboard-key>
</mds-keyboard>

<!-- CORRECT -->
<mds-keyboard try>
  <mds-keyboard-key name="control"></mds-keyboard-key>
  <mds-keyboard-key name="z"></mds-keyboard-key>
</mds-keyboard>
```

#### Do Not Use a Generic `name` String Outside the Key Dictionary

`name` is a `KeyboardKeyName` union type. Passing an arbitrary string (e.g. `"ctrl"`, `"cmd"`, `"esc"`) that is not in the dictionary causes a runtime lookup failure because the component reads `keyboardKeysData[name]` without a guard.

```html
<!-- INCORRECT -->
<mds-keyboard>
  <mds-keyboard-key name="ctrl"></mds-keyboard-key>
  <mds-keyboard-key name="cmd"></mds-keyboard-key>
  <mds-keyboard-key name="esc"></mds-keyboard-key>
</mds-keyboard>

<!-- CORRECT -->
<mds-keyboard>
  <mds-keyboard-key name="control"></mds-keyboard-key>
  <mds-keyboard-key name="command"></mds-keyboard-key>
  <mds-keyboard-key name="escape"></mds-keyboard-key>
</mds-keyboard>
```

#### Do Not Slot Content Inside `<mds-keyboard-key>`

`<mds-keyboard-key>` exposes no default or named slot. Any slotted content is ignored; the glyph is derived entirely from the `name` prop.

```html
<!-- INCORRECT -->
<mds-keyboard>
  <mds-keyboard-key name="control">Ctrl</mds-keyboard-key>
</mds-keyboard>

<!-- CORRECT -->
<mds-keyboard>
  <mds-keyboard-key name="control"></mds-keyboard-key>
</mds-keyboard>
```

#### Customize via CSS Custom Properties, Not Shadow-Piercing Selectors

The supported customization surface is the public `--mds-keyboard-key-padding` CSS custom property. Piercing shadow DOM via `::part()` on undocumented internals, `>>>`, or class hacks couples your code to the implementation and will break on minor releases.

```css
/* INCORRECT */
mds-keyboard-key >>> .physical-key {
  background-color: blue;
}

/* CORRECT */
mds-keyboard-key {
  --mds-keyboard-key-padding: calc(var(--spacing) * 300);
}
```
