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

# mds-keyboard

> `@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>` web component renders a keyboard shortcut as a row of physical-looking keycaps, acting as the compound parent for one or more slotted `<mds-keyboard-key>` children. It has no direct HTML equivalent; it visualizes a key combination (e.g. `Ctrl + C`) and can optionally let the user verify that combination by typing it.

#### Semantic Behavior

- **Default slot is the key sequence**: The component projects slotted `<mds-keyboard-key>` elements and automatically inserts a `+` separator between consecutive keys.
- **Compound parent**: It reads each child key's `name` to build the expected combination; during a test the children are toggled to their `pressed` state.
- **Test mode (`try`)**: When enabled the component appends a trigger button and a tooltip; clicking the button (or pressing Enter or Space on it) captures keystrokes and, at the first release of a key pressed during the test, compares the typed combination against the slotted keys, in any order. The release of the key that started the test is not part of it.
- **Result feedback**: A pass shows a "done" icon, a fail shows a "close" icon, and the tooltip surfaces the localized success or error message; the outcome is also reflected on the host via the `test` attribute.
- **Localization**: Trigger label, tooltip copy, and error messages resolve through the locale system (el/en/es/it).

#### Properties & Visual Configurations

This component does not use the shared `variant` / `tone` ladders from [`agents/variants.md`](../../../../agents/variants.md).

#### Other behavioral props

- **`try`** opts the keyboard into interactive verification mode. Enable it only when you want the user to be able to confirm a shortcut by typing it; leave it unset for a purely presentational shortcut display.
- **`test`** reflects the verification outcome (`'pass'` / `'fail'`) onto the host. It is primarily driven by the test flow and is mainly useful as a styling/state hook rather than a value you set yourself.

## 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--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 |
| --- | --- | --- | --- | --- |
| `test` | `test` | `"fail" \| "pass" \| undefined` | - | Shows the keyboard key combination test result |
| `try` | `try` | `boolean \| undefined` | - | Sets if the keyboard key combination test is enabled |

## Slots

| Slot | Description |
| --- | --- |
| (default) | Add `mds-keyboard-key` elements or `components` to this slot. |

## CSS custom properties

| Property | Description |
| --- | --- |
| `--mds-keyboard-background` | Set the background color of the keyboard area. |
| `--mds-keyboard-color` | Set the text color of the keyboard area, will impact on `mds-keyboard-key` component. |
| `--mds-keyboard-padding` | Set the padding of the keyboard area. |

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

## Dependencies

Uses: `mds-text`, `mds-button`, `mds-tooltip`.
