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

# mds-keyboard - mistakes

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

Common incorrect uses of `<mds-keyboard>`. 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 Slot Raw Text or `<kbd>` Elements

The default slot expects `<mds-keyboard-key>` children only. Slotting plain text, `<kbd>`, or other HTML breaks the separator injection logic and the test-mode key matching.

```html
<!-- INCORRECT -->
<mds-keyboard>
  <kbd>Ctrl</kbd>
  <kbd>S</kbd>
</mds-keyboard>

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

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

The component inserts a styled `+` between consecutive keys automatically. Adding your own separator duplicates it and breaks the visual rhythm.

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

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

#### Do Not Set `try="false"` to Disable Test Mode

`try` is a boolean attribute: remove it (or leave it unset) to keep the component in display-only mode. A string value is fragile: `"false"` is read as `false` on this component, but the attribute stays on the element until the component renders (attribute selectors and scripts reading it see it set). Never write a boolean as a string.

```html
<!-- INCORRECT -->
<mds-keyboard try="false">
  <mds-keyboard-key name="escape"></mds-keyboard-key>
</mds-keyboard>

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

#### Do Not Set `test` as a Static Attribute to Signal State

`test` is a reflected output prop driven by the component's own verification flow. Setting it as a static HTML attribute paints the pass / fail state without any attempt behind it, and the next attempt overwrites it.

```html
<!-- INCORRECT -->
<mds-keyboard test="pass">
  <mds-keyboard-key name="enter"></mds-keyboard-key>
</mds-keyboard>

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

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

`<mds-keyboard-key>` is a compound child and communicates with the parent via the Stencil DOM tree. Rendering it standalone loses the compound layout, the `+` separator, and test-mode driven `pressed` toggling.

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

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

#### Do Not Customize Colors with Raw CSS Values Instead of Tokens

Setting `--mds-keyboard-background` or `--mds-keyboard-color` to a raw hex or `rgba()` literal bypasses the palette layer and breaks dark mode. Always use a semantic color role, `rgb(var(--magma-<role>))` ([`agents/color.md`](../../../../agents/color.md)).

```css
/* INCORRECT */
mds-keyboard {
  --mds-keyboard-background: #1a1a2e;
  --mds-keyboard-color: #e0e0e0;
}

/* CORRECT */
mds-keyboard {
  --mds-keyboard-background: rgb(var(--magma-surface-inverse));
  --mds-keyboard-color: rgb(var(--magma-on-inverse));
}
```
