# Sensible Defaults and Keyboard Layouts

TanStack Hotkeys chooses defaults so common shortcuts need no configuration. Without any options, `Mod+S` maps to Command+S on macOS and Control+S elsewhere, blocks the browser's Save dialog, keeps working inside text fields, and matches across keyboard layouts.

This guide explains each default and how to override it.

## At a glance

| Behavior | Default | Change it with |
| --- | --- | --- |
| `Mod` modifier | Command on macOS, Control on Windows and Linux | `platform` |
| Key identity | Character the key types (`event.key`), with position fallback | `[KeyS]` physical bindings |
| Modifiers | Exact match required | List every modifier in the binding |
| Typing in inputs | Single keys and `Shift` or `Alt` chords ignored, while `Control` or `Meta` chords and `Escape` fire | `ignoreInputs` |
| Browser behavior | Calls `preventDefault()` and `stopPropagation()` when matched | `preventDefault`, `stopPropagation` |
| Disabled or inactive hotkeys | Browser acts on the key | `preventDefault: 'always'` |
| When a chord fires | On `keydown`, and on auto-repeat while held | `eventType`, `requireReset` |
| Listener target | `document` | `target` |
| Event phase | Bubble phase (after widget handlers inside target) | `capture` |
| Already-prevented keys | Hotkeys still fire | `ignoreDefaultPrevented` |
| Sequence step timeout | 1 second (`1000` ms) | `timeout` |
| Duplicate registrations | Allowed, with a development console warning | `conflictBehavior` |
| Recording | Portable name or physical fallback. `Escape`, `Tab`, `Shift+Tab` cancel | `recordBy`, `recordTab`, recorder options |
| Display formatting | Symbols on macOS (`⇧ ⌘ S`), text elsewhere (`Ctrl+Shift+S`) | Label formatter options (such as `useFormatForDisplay`) |

## `Mod` follows the platform

`Mod` resolves to the platform's primary shortcut modifier: Command (`Meta`) on macOS, and Control on Windows and Linux. A single `Mod+S` binding adapts to each user's operating system automatically.

- **Platform detection.** Detected from `navigator` in the browser, defaulting to `'linux'` during server rendering where `navigator` doesn't exist. Pass `platform: 'mac' | 'windows' | 'linux'` to override detection in tests or when previewing another OS.
- **Canonical storage.** Hotkeys normalize to canonical strings. On Windows and Linux, `Control+S` and `ctrl+s` store as `Mod+S`. On macOS, `Control+S` stays `Control+S` because Control isn't the primary modifier. That's why `Mod+S` and `Control+S` collide on Windows and Linux, not on macOS.

## Keys match the character the user types

Logical bindings like `Mod+S` or `?` match `event.key`, which is the character produced on the user's active keyboard layout. Matching is case-insensitive, so `S` and `s` are identical. A user on Dvorak, Colemak, or AZERTY presses the key labeled `S` to trigger `Mod+S`, wherever it sits physically.

### When matching falls back to physical position

`event.key` doesn't always tell you which key was pressed, so the matcher falls back to the key's position (`event.code` or keycap identity) in four cases:

- **Non-Latin layouts.** On a Russian layout, the `S` key types `ы`. `Mod+S` still matches so shortcuts work without switching layouts.
- **macOS `Option`.** Option changes characters (`Option+S` types `ß`, German `Option+L` types `@`). `Alt+S` and `Alt+L` still match based on the letter printed on the key (`event.keyCode`, falling back to position when `keyCode` isn't a letter). On a French AZERTY Mac, `Alt+A` fires on the key labeled `A` (the US `Q` position).
- **Dead keys and the digit row.** Dead keys report `'Dead'`, and layouts like AZERTY type `&` and `é` on the unshifted digit row. Position fallback keeps `Mod+1` working.
  - *Zoom shortcut exception.* When a digit key types `-`, `+`, or `=` (such as `-` on AZERTY's `6` key), pressing `Control` (or `Command` on macOS) with it lets the browser zoom instead of firing `Mod+6`. `Ctrl+Shift+6` still fires `Mod+6`.
  - *Rare layouts without shifted digits.* Thai (`3` key) and Programmer Dvorak (`6` and `9` keys) don't type digits even with Shift. Add a physical fallback like `Mod+[Digit3]` if you need those keys everywhere.
- **Symbols typed with Shift on digits.** `Shift+1` types `!` on a US layout, and `Shift+1` still matches.

### When the reported character wins (and layout quirks)

Outside the fallbacks above, the character the key types wins even if that key sits in a different spot than on US QWERTY:

- **Letters and non-digit symbols.** Outside the digit row, ASCII letters never fall back. ASCII symbols fall back only with `Shift` or when macOS `Option` typed them on a letter key. On AZERTY, the key in the US `/` position types `+`, so `Cmd++` zooms instead of firing `Mod+/`. On Dvorak, typing `'` doesn't fire `Q`.
- **Accented Latin letters (`ü`, `ö`, `ø`).** Match only themselves when pressed alone, but fall back on punctuation keys when held with `Control` or `Command`. German `Cmd+ü`, for example, still triggers `Mod+[`.
- **Turkish `ı` and `İ`.** Treated as distinct letters, not case variants of `I` and `i`. `ı` and `İ` match only themselves. `I` matches `i` and `I`, and also falls back on `ı`, with an explicit `ı` binding taking priority.
- **macOS `Cmd+Shift+symbol`.** With `Command` held, macOS browsers report the unshifted key (`/` instead of `?`), so `Mod+?` can't match there and `Mod+/` won't match because `Shift` is held. Bind the Shift form instead: `Mod+Shift+/` for `Cmd+?`, and `Mod+Shift+=` alongside `Mod+=` for zoom in. On German QWERTZ, symbols typed with `Shift` (such as `/` on `Shift+7`) also report the unshifted character (`7`) with `Command` on macOS, so register `Mod+Shift+7` as well. On Windows and Linux, `Ctrl+Shift+7` on QWERTZ fires `Mod+Shift+/` when registered, and `Mod+/` otherwise. The digit row is exempt so AZERTY Mac `Cmd+Shift+1` still fires `Mod+1`.
- **Named keys and numpad.** Named keys never fall back. With NumLock off, Numpad `1` reports `End` and triggers `End` rather than `1`, and Numpad `5` fires no digit even in Firefox (`Unidentified`).
- **Priority.** When one press could match both an exact character binding and a fallback on the same target, the exact match wins.

### Match a key's position instead

When a shortcut should follow physical keyboard geometry instead of characters, such as `W`, `A`, `S`, `D` game movement, use a physical binding. Physical bindings match `event.code` directly and ignore layout:

| Binding | Matches |
| --- | --- |
| `Mod+S` or `{ key: 'S', mod: true }` | The character `S` (`event.key`), with the fallbacks above |
| `Mod+[KeyS]` or `{ code: 'KeyS', mod: true }` | The physical `S` key on a US layout (`event.code`) |
| `Enter` | Either Enter key, including the numpad's |
| `[Enter]` or `[NumpadEnter]` | Only that specific Enter key |

- **String syntax.** Wrap every physical code in brackets, including keys that share a logical name like `[Enter]` and `[F13]`. Editor autocomplete and type checking apply to all codes.
- **Object syntax.** Use `code` for physical bindings and `key` for logical ones. Never pass both, and never put brackets inside `key`.
- **Callback context.** `context.parsedChord.code` (and `step.code` in sequences) is only defined for physical bindings. Check `code !== undefined` before reading it.
- **Display labels.** Brackets are stripped in UI labels, so `Mod+[KeyS]` displays as `⌘ S` on macOS. In Chromium browsers (Chrome and Edge), your adapter's label formatter swaps physical keys for the character printed on the user's actual layout. Firefox and Safari fall back to the US label.

### Type keys from other keyboard layouts

By default, hotkey strings type-check against US QWERTY keys. Most apps never need to change this, because A to Z, 0 to 9, and common US punctuation already match across international layouts at runtime.

To type-check layout-specific keys such as `Ö`, `ß`, or `§`, register those layout sets through module augmentation (see your framework's Keyboard Layouts guide). Registering sets changes types only. Matching behavior and bundle size stay identical.

Each set covers layout-specific keys and punctuation typed unshifted or with `Shift` across Windows, macOS, and Linux, omitting dead keys and `AltGr` or `Option` characters. Letters typed with `Shift` require `Shift+` in the hotkey.

- **Americas.** `UsKeys`, `BrazilianKeys`, `LatinAmericanKeys`, `CanadianFrenchKeys`
- **Western Europe.** `UkKeys`, `GermanKeys`, `AustrianKeys`, `SwissGermanKeys`, `SwissFrenchKeys`, `FrenchKeys`, `BelgianKeys`, `SpanishKeys`, `PortugueseKeys`, `ItalianKeys`
- **Nordic.** `DanishKeys`, `NorwegianKeys`, `SwedishKeys`, `FinnishKeys`, `IcelandicKeys`
- **Central and Eastern Europe.** `CzechKeys`, `SlovakKeys`, `HungarianKeys`, `CroatianKeys`, `SlovenianKeys`, `SerbianLatinKeys`, `EstonianKeys`, `LithuanianKeys`, `RomanianKeys`, `TurkishKeys`
- **Non-Latin.** `GreekKeys`, `RussianKeys`, `UkrainianKeys`, `BulgarianKeys`, `HebrewKeys`

Polish and Latvian share US QWERTY base keys without `AltGr`, and most Dutch users use US International, so they don't need a separate set.

## Modifiers must match exactly

`Mod+S` won't fire on `Mod+Shift+S`, and `K` won't fire on `Shift+K`. Exact matching keeps `Mod+Z` (undo) and `Mod+Shift+Z` (redo) from colliding.

- **Symbols typed with `Shift`.** Printable symbols like `?`, typed with `Shift+/` on US keyboards, match without listing `Shift+`. Letters always require explicit `Shift+` (`K` versus `Shift+K`).
- **iOS auto-capitalization.** The iOS on-screen keyboard sometimes reports Return as `Shift+Enter` at the start of a sentence. If an `Enter` shortcut must work inside an editor (`ignoreInputs: false`), register `Shift+Enter` for it too.
- **Modifier-only hotkeys are rejected.** Every hotkey needs a non-modifier key. TypeScript rejects strings like `Shift+Alt+Mod` or `Ctl+K`. Plain JS or saved strings log a dev warning and register nothing. Use the held-key APIs to react to modifiers alone.
- **AltGr is treated as character input.** On Windows and Linux, `AltGr` types characters like `@` or `€`. Those match character bindings, never `Control+Alt` shortcuts, so typing an email doesn't trigger commands. On Windows, Left Ctrl + Left Alt acts as `AltGr` on layouts that have it, so avoid `Control+Alt` with letters, digits, and symbols when users type in other languages (German `Ctrl+Alt+E` types `€` and Polish `Ctrl+Alt+A` types `ą` instead of triggering `Control+Alt+E` or `Control+Alt+A`). When `AltGr+key` produces no new character (such as `AltGr+F`), it doesn't fire `F`. Because Windows reports `AltGr` as Control+Alt, `AltGr+Home` triggers `Control+Alt+Home` on Windows, matching native apps.
- **IME composition pauses hotkeys.** While users compose text with an IME (Japanese, Chinese, Korean), all hotkeys pause. This includes the `Enter` Safari emits right after composition ends, so `Enter`, `Escape`, and arrow keys belong to the IME.

## Typing in inputs does not trigger shortcuts

A hotkey bound to `K` shouldn't fire when the user types "okay" into a search box. By default, `ignoreInputs` is `'auto'`, which decides based on the hotkey itself (using the first step for sequences):

| Hotkey | Behavior in inputs | Why |
| --- | --- | --- |
| `K`, `Shift+K`, `Alt+K`, `?` | Ignored | These keys type text |
| `Mod+S`, `Control+K`, `Meta+Enter` | Fires | Primary shortcuts shouldn't break while editing |
| `Escape` | Fires | Users expect `Escape` to close dialogs from inside inputs |

These elements count as inputs, including inside open shadow roots:

- Editable `<input>` types (`text`, `search`, `email`, `number`, and date or time types, unless `readOnly`)
- Non-`readOnly` `<textarea>` and `<select>` elements
- `contenteditable` elements and `role="textbox"` or `role="searchbox"`
- Elements hiding focus inside a closed shadow root, or form-associated custom elements without a `role` attribute

Non-text controls (checkboxes, radios, ranges, color, file, and buttons) are not text inputs, so `K` still fires there. They only protect the specific keys they use (see below). Custom elements can set a `role` like `role="checkbox"` for the same behavior.

A hotkey whose `target` is the input element itself always receives its events. To let a shortcut like `Enter` submit a form from its text fields, set `ignoreInputs: false`. To ignore even `Mod` shortcuts inside inputs, set `ignoreInputs: true`.

## Focused controls keep their own keys

Native controls and ARIA widgets use keys like `Space`, `Enter`, and arrow keys for themselves. When `ignoreInputs` is active (`true` or `'auto'`), hotkeys skip those keys while a matching control or element inside it has focus:

| Focused control | Keys it keeps |
| --- | --- |
| `<button>`, button, image, color, and file inputs, `<summary>`, `role="button"` | `Enter`, `Space` |
| Checkbox inputs, `role="checkbox"`, `"switch"`, `"radio"` | `Space` |
| Radio inputs, `role="radiogroup"` | Arrow keys, `Space` |
| Range inputs, `role="slider"` | Arrow keys, `Home`, `End`, `PageUp`, `PageDown` |
| Read-only text inputs | `ArrowLeft`, `ArrowRight`, `Home`, `End` |
| Read-only textareas | Arrow keys, `Home`, `End`, `PageUp`, `PageDown` |
| Links with `href`, `role="link"` | `Enter` |
| `role="tab"`, `"option"`, `"treeitem"`, `"menuitem"` (all forms) | `Enter`, `Space` |
| `role="menu"`, `"menubar"`, `"tree"` | Arrow keys, `Home`, `End`, `Enter`, `Space`, typeahead characters |
| `role="listbox"` | Vertical arrows (horizontal if `aria-orientation="horizontal"`), `Home`, `End`, `Enter`, `Space`, typeahead |
| `role="combobox"` (without a text field) | `ArrowUp`, `ArrowDown`, `Home`, `End`, `Enter`, `Space`, typeahead |
| `role="tablist"` | Horizontal arrows (vertical if `aria-orientation="vertical"`), `Home`, `End`, `Enter`, `Space` |
| `role="toolbar"` | Horizontal arrows (vertical if `aria-orientation="vertical"`), `Home`, `End` |
| `role="grid"`, `"treegrid"` | Arrow keys, `Home`, `End`, `PageUp`, `PageDown`, `Enter`, `Space` |
| `role="spinbutton"` | `ArrowUp`, `ArrowDown`, `Home`, `End`, `PageUp`, `PageDown` |

- `Control`, `Meta`, and `Alt` shortcuts are never skipped here. `Enter` and `Space` are skipped only without modifiers, and navigation or typeahead keys are also skipped with `Shift` for selection extension.
- Controls only reserve keys when they sit *inside* the hotkey's `target`. A hotkey targeted directly at a listbox receives arrow keys so the widget can implement its own navigation. Set `ignoreInputs: false` to bypass this completely.
- The hotkey recorder skips only text fields, so you can still record `Enter` or `Space` while the trigger button keeps focus.

## The browser's action is prevented

`preventDefault` and `stopPropagation` both default to `true`. Binding `Mod+S` shouldn't open the browser's Save Page dialog, and binding `Mod+K` shouldn't jump to the address bar or fire duplicate listeners higher in the DOM.

- Unmatched keys are never touched.
- In a sequence like `['Mod+K', 'Mod+C']`, every matching step calls `preventDefault()`, while `stopPropagation()` runs only on the final step so earlier keys still reach other listeners.
- To observe a shortcut without blocking it, set either option to `false`.
- Browsers and operating systems reserve certain shortcuts (`Mod+T`, `Mod+N`, `Mod+W`, `Alt+Tab`, `Command+Tab`) before they ever reach the page. Pick other keys for your app.
- Binding `Tab`, `Shift+Tab`, or `F6` on `document` prevents focus movement across buttons and links. Give those shortcuts an element `target` instead.

## Hotkeys that can't fire leave the key alone

If a hotkey is disabled (`enabled: false`) or its scope is inactive or suspended, it doesn't call `preventDefault()`. That means pressing `Mod+S` while saving is disabled opens the browser's Save dialog.

For most shortcuts, setting `preventDefault: 'always'` in your shared defaults is better. With `'always'`, a disabled or suspended chord still prevents the browser's default action:

- It never stops propagation, so other listeners still see the key.
- It still respects `ignoreInputs` while typing in fields.
- If another active hotkey handles the key, that hotkey's options take over.
- Sequences treat `'always'` as `true`.

Don't use `'always'` on hotkeys you turn off specifically to hand keys back to the browser. Set `preventDefault: true` on those instead:

- **Clipboard and editing chords.** `Mod+C`, `Mod+A`, and `Mod+Z` enabled only while canvas cells are selected would block native copy and undo in text inputs if `'always'` were set.
- **Single-key shortcuts.** Shortcuts behind an accessibility off switch would keep blocking `Space`, arrow keys, or `/` when turned off.
- **`Tab` hotkeys.** Disabling them would still trap focus.

## Single-key shortcuts need an off switch

Ignoring text inputs prevents `K` from firing while typing, but speech-input users dictate words as single keystrokes. Under [WCAG 2.1.4](https://www.w3.org/WAI/WCAG22/Understanding/character-key-shortcuts.html), any shortcut using only letters, numbers, or symbols (including `Shift+K` or a sequence like `['G', 'G']`) must satisfy at least one of these conditions:

- **Turn it off.** Wire `enabled` to a user preference.
- **Remap it.** Let users add a modifier through app hotkeys and the recorder.
- **Scope it to focus.** Give it an element `target` so it fires only while that widget is focused.

Shortcuts using `Mod`, `Control`, or `Alt`, as well as non-character keys like `Escape` and `F1` to `F12`, don't need this.

## Chords fire on keydown and repeat while held

By default, chords fire on `keydown` and repeat on each OS auto-repeat tick while held, which suits actions such as holding `Mod+Z` for undo or scrolling.

- **Prevent key repeat (`requireReset: true`).** Ideal for toggles like opening and closing panels so holding the key doesn't flicker. Fires once until you release the key or any modifier, or trigger a fresh non-repeat press (so lost macOS `Command` keyups never get a key stuck).
- **Fire on release (`eventType: 'keyup'`).** Fires when either the key or one of its modifiers is released after a matching press, provided no other key was pressed in between. This works reliably even on macOS (which drops keyups while `Command` is held) and still prevents the `keydown` browser default unless `preventDefault: false`.

## Listeners attach to the document

Hotkeys listen on `document` by default so they work regardless of focus. Internally, TanStack Hotkeys attaches at most one `keydown` and one `keyup` listener per target (plus a capture pair if any hotkey uses `capture: true`), no matter how many shortcuts you register.

- Pass an element `target` to scope a shortcut to focus inside that element, adding `tabIndex` if the element isn't natively focusable.
- Hotkeys can target same-origin iframes or popups (`document`, `window`, or an element inside them). `ignoreInputs` works inside those frames automatically.
- No listeners are attached during server rendering.

## Hotkeys run after the page's own handlers

Hotkeys listen in the bubble phase by default, so a focused widget's own `onKeyDown` handler runs first and can call `stopPropagation()`.

- **Delegated event frameworks (React, Svelte, Solid, Octane).** Because those frameworks delegate `onKeyDown` at the root or document, a hotkey with an element `target` waits until after delegated handlers on the page run too. That means `stopPropagation()` on an element hotkey won't stop an outer framework `onKeyDown`. In other frameworks, handlers outside the target run after the hotkey.
- **Override widgets with `capture: true`.** When an app-level shortcut must run before a widget (such as `Mod+Backspace` closing a view before a tab strip treats it as Backspace), set `capture: true`. It works for both `keydown` and `keyup` and still respects `ignoreInputs`.

## Component libraries that handle the same keys

UI libraries close dialogs, popovers, and menus on `Escape`, and rich-text editors handle chords like `Mod+B`. When your app binds the same key, a single keystroke can reach both unless they coordinate.

### Skip keys a library already handled

If a component library or editor calls `preventDefault()` on a key without calling `stopPropagation()`, your hotkey still sees the event. Set `ignoreDefaultPrevented: true` in your shared defaults (see [Changing the defaults](#changing-the-defaults)) so hotkeys skip any event another listener already prevented. A hotkey's own `preventDefault` is ignored for this check, so your element and document hotkeys still compose.

> [!NOTE]
> `ignoreDefaultPrevented` only sees `preventDefault()` calls from listeners that run *before* yours (on a child element, or in the capture phase). Libraries that attach a fresh `document` listener only when an overlay opens run *after* your hotkeys, so the option can't help there. For `Escape` on overlays, see [Let an open overlay handle Escape](#let-an-open-overlay-handle-escape).

Turn on `ignoreDefaultPrevented: true` if you use:

- Angular Material or the Angular CDK (dialogs, bottom sheets, menus, and selects)
- spartan/ui
- ng-zorro-antd (modals, selects, tooltips, and popovers)

PrimeNG dialogs, drawers, and popovers, as well as ng-bootstrap dropdowns and typeaheads, handle Escape after your hotkeys. Their overlays still receive Escape through overlay detection below.

### Let an open overlay handle Escape

By default, TanStack Hotkeys keeps `Escape` working for the innermost open overlay. When focus is inside a modal or menu, `Escape` hotkeys outside it are automatically skipped (no callback, no `preventDefault()`, no `stopPropagation()`). A hotkey targeted at the overlay, or at an element inside it, still receives `Escape`.

TanStack Hotkeys detects overlays at `window` before `document` listeners run:

- Native `<dialog>` elements (`showModal()`, or non-modal with `closedby="any"` or `closedby="closerequest"`), ignoring `<dialog closedby="none">`. When modal dialogs stack, only the top one counts.
- Open popovers (`popover` or `popover="auto"`), excluding `popover="manual"`
- The innermost element around focus (other than `<dialog>`) with `role="dialog"`, `role="alertdialog"`, `role="menu"`, an expanded `combobox` (`aria-expanded="true"`), or a focused `aria-expanded="true"` trigger with `aria-haspopup` other than `"false"`

When writing your own `Escape` hotkeys:

1. **Let the browser close native `<dialog>` and `popover`.** Build overlays on `<dialog>` with `showModal()` or `popover` (`"auto"`) without registering a custom `Escape` hotkey. A `popover="manual"` popover doesn't close on Escape, so close it with an `Escape` hotkey targeted at it. For a dialog users cannot dismiss, use `<dialog closedby="none">` and also call `preventDefault()` on its `cancel` event for browsers without `closedby`.
2. **Target custom overlays directly.** For a custom ARIA dialog you manage yourself, pass `target` on the overlay element rather than registering a global `Escape`.
3. **Guard global `Escape` when needed.** Automatic detection can't see overlays in these cases:
   - An overlay without focus inside it (such as a popover in a shadow root while its trigger has focus)
   - An overlay without one of the ARIA or native roles above (such as `@keydown.escape.window`)
   - An overlay inside a closed shadow root
   - An overlay closed by a `window` capture listener added before the first registered hotkey

   Wrap those in an `exclusive` scope while open, or pass `enabled: !open` to your global `Escape` hotkey while keeping the default `preventDefault` (not `'always'`) so the overlay still receives `Escape`.
4. **Keep `Escape` out of page sections and sequences.** Inside `role="dialog"` or `role="alertdialog"`, hotkeys in any named scope keep `Escape`, so a page section's `Escape` hotkey steals it from a library's dialog, and a sequence step on `Escape` competes with every overlay.

While focus is inside a `role="dialog"` or `role="alertdialog"` element, hotkeys in any named scope keep `Escape` (regardless of `target`), so a dialog component using its own scope can still close itself while an inner combobox or menu still closes first. Native `<dialog>` and `popover` overlays take `Escape` before any hotkey outside them regardless of scope. Make a dialog's scope `exclusive` if other named scopes can stay active behind it.

Tested: Angular CDK dialogs and Angular Material dialogs close on Escape without triggering outer hotkeys.

Not yet tested with this rule: ng-bootstrap and PrimeNG.

See [Group hotkeys into scopes](../framework/angular/guides/provide-hotkeys-and-scopes.md#group-hotkeys-into-scopes) to give an overlay its own scope.

## Sequences allow 1 second between steps

A sequence like `['G', 'G']` completes when each step arrives within `1000` ms (`timeout`). While a sequence is in progress:

- Pressing a standalone modifier (`Shift`) doesn't break the sequence, so `['Shift+R', 'Shift+T']` works naturally.
- Lock keys (`CapsLock`, `NumLock`), `Fn`, and dead keys don't reset progress unless they match a step of another sequence.
- Key auto-repeat doesn't count as a second step. Holding `G` won't trigger `['G', 'G']`.
- Pressing a wrong key clears progress, unless that key starts the sequence. In that case it begins a fresh attempt, so `G X G G` still fires `['G', 'G']`.
- Progress clears automatically when the timeout expires, so UI indicators disappear on time.

## Duplicate registrations warn

Registering two hotkeys with the same canonical binding, target, scope, and event type logs a console warning in development and runs both callbacks. Set `conflictBehavior` to `'replace'`, `'error'`, or `'allow'` to customize this.

Dev warnings check `process.env.NODE_ENV`, so bundlers strip them in production. If you load the library without a bundler (no `process` global), use `validateHotkey` or `assertValidHotkey` to validate strings, or set `conflictBehavior: 'error'`.

## Recording captures what the user pressed

With the default `recordBy: 'auto'`, the hotkey recorder writes portable strings just as you would by hand. Command+S on macOS and Control+S elsewhere both record `'Mod+S'`.

- **Fallback to physical codes.** When presses aren't portable across layouts or operating systems, the recorder falls back to bracketed physical codes: `Shift+/` becomes `Shift+[Slash]`, `Shift+1` becomes `Shift+[Digit1]`, macOS `Option+1` becomes `Alt+[Digit1]`, plus dead keys (except `Option+letter` accents like `Alt+E`) and numpad keys. Non-Latin letter presses record as their US position (`Control+ы` becomes `Mod+S`).
- **Explicit modes.** Set `recordBy: 'code'` to always record physical positions (for games), or `recordBy: 'key'` to always record typed characters (`Option+S` becomes `Alt+ß`).
- **Conflict detection.** Enable `detectConflicts` (or pass `context` to `findConflicts`) to catch collisions even when a recording (`Shift+[Slash]`) and a declared hotkey (`?`) are spelled differently.

While recording is active:

- `Escape`, `Tab`, and `Shift+Tab` cancel so keyboard users aren't trapped (`recordTab: true` records Tab instead).
- `Backspace` or `Delete` undoes the last sequence step, or clears when empty.
- `Enter` commits multi-step sequences (`maxSteps: Infinity`).
- Existing registered hotkeys pause automatically, while typing in other inputs passes through.
- `AltGr` presses are rejected unless `recordBy: 'key'`, except `AltGr+Home` on Windows which records as `Control+Alt+Home`.

## Held keys reset when the window loses focus

Key state tracking updates on `keydown` and `keyup`, with automatic safeguards against stuck keys:

- **Focus loss and context menus.** Switching apps (`Command+Tab`), hiding the tab, or opening a native context menu clears held keys. A custom menu calling `preventDefault()` on `contextmenu` keeps state.
- **macOS `Command` quirk.** Releasing `Command` on macOS clears other held keys because macOS swallows keyups for keys released while `Command` is held. Other modifiers and platforms keep their keyups.
- **Swallowed modifier keyups.** Shortcuts like macOS screenshot (`Cmd+Shift+4`) steal the modifier `keyup` without blurring the window. Held modifiers resync on the next real user keyboard or mouse event.

## Display matches the platform

Label formatters like `useFormatForDisplay` match OS conventions. `Mod+Shift+S` becomes `⇧ ⌘ S` on macOS and `Ctrl+Shift+S` on Windows and Linux, and sequence steps join with spaces (`G G`). Pass `useSymbols: false` for text names on macOS, or `keyLabels` to rename individual keys.

## Changing the defaults

Every option above can be set per registration. To change defaults across your app, configure your framework adapter:

Pass `defaultOptions` to `provideHotkeys`. See [Hotkey options](../framework/angular/guides/hotkeys.md#hotkey-options) in Register Hotkeys.
