Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
23 changes: 23 additions & 0 deletions .changeset/format-for-aria.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
'@tanstack/hotkeys': minor
'@tanstack/react-hotkeys': minor
'@tanstack/preact-hotkeys': minor
'@tanstack/octane-hotkeys': minor
'@tanstack/solid-hotkeys': minor
'@tanstack/vue-hotkeys': minor
'@tanstack/svelte-hotkeys': minor
'@tanstack/angular-hotkeys': minor
'@tanstack/ember-hotkeys': minor
'@tanstack/lit-hotkeys': minor
'@tanstack/alpine-hotkeys': minor
---

Add `formatForAria` to format hotkeys for the `aria-keyshortcuts` attribute. `formatForAria('Mod+K')` returns `'Meta+K'` on macOS and `'Control+K'` elsewhere. Modifiers and keys use the ARIA specification's names, with `Space` for the space bar, `Plus` for the plus key, and the key at that position for physical bindings. Punctuation in a logical hotkey stays as written, so `'?'` gives `?` rather than `Shift+/`. `formatForAria` returns `undefined` for multi-step sequences, standalone modifiers, empty hotkeys, and physical codes with no key value so the attribute is omitted.

Each framework adapter exports a formatter that fills in the configured platform and the user's keyboard layout, and returns `undefined` while the hotkey can't fire, so screen readers announce only working shortcuts:

- `useFormatForAria` (React, Preact, Octane, Vue, Ember)
- `createFormatForAria` (Solid, and on Alpine scopes)
- `getFormatForAria` (Svelte)
- `injectFormatForAria` (Angular)
- `FormatForAriaController` (Lit)
17 changes: 17 additions & 0 deletions .changeset/suspend-character-keys.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
'@tanstack/hotkeys': minor
'@tanstack/react-hotkeys': minor
'@tanstack/preact-hotkeys': minor
'@tanstack/octane-hotkeys': minor
'@tanstack/solid-hotkeys': minor
'@tanstack/vue-hotkeys': minor
'@tanstack/svelte-hotkeys': minor
'@tanstack/angular-hotkeys': minor
'@tanstack/hotkeys-devtools': patch
---

Add `HotkeyManager.suspendCharacterKeys()` and the `suspendCharacterKeys` provider option so apps can let users turn off character key shortcuts for WCAG 2.1.4.

A character key shortcut is a document-level hotkey whose every step types a character, alone or with `Shift`, such as `'K'`, `'?'`, `'Shift+K'`, `'Space'`, or `['G', 'H']`. While suspended, those hotkeys do not fire and report the status `'suspended'`. Hotkeys with `Control`, `Alt`, or `Meta`, non-character keys such as `Escape` or `F1`, and hotkeys targeted at an element keep working.

Suspensions are counted like scope activations, and `HotkeyScopesState` now includes `characterKeysSuspended`. Bind the provider option to a user setting with `<HotkeysProvider suspendCharacterKeys={!settings.characterKeyShortcuts}>` (or `provideHotkeys({ suspendCharacterKeys })` in Angular).
3,977 changes: 2,139 additions & 1,838 deletions .intent/review-state.json

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions _artifacts/skill_spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,9 @@ The skills teach agents to use those APIs directly. The core skills hold the fra
- **Source:** branch `feat/keyboard-layout-labels`. Each adapter's label primitive is now the documented way to format every label in component code, not only in server-rendered apps, because it fills in both the provider's platform and the user's keyboard layout. Each adapter exports a deprecated `formatForDisplay`, the core function, that points to the primitive. Lit gains `FormatForDisplayController` and Alpine gains a scope's `createFormatForDisplay()` and a scope `platform` option. Examples name the primitive's result `formatForDisplay`.
- **Changes:** every framework skill's opening snippet and app hotkeys reference use the label primitive, its API table row says to use it for every label and that layout labels work only in Chromium browsers, the re-export sentence says the plain export is deprecated and is still the function to call outside a component, and the server rendering pitfall no longer recommends the plain function. `hotkeys-core` points label maps to the adapter's label primitive. The Angular skill's scope pitfall now says a label also activates a lazily created provider. `domain_map.yaml` and `skill_tree.yaml` are unchanged.
- **Checks:** each adapter tests that its deprecated export is the core function; Lit and Alpine have a label primitive test file. `intent validate` passes. Not run: fresh-consumer sessions.

### Source sync — 2026-11-27 — accessible shortcuts

- **Source:** branch `feat/format-for-aria` from `d7e198df`. Core adds `formatForAria`, which formats a hotkey as an `aria-keyshortcuts` value, and each adapter has an ARIA formatter beside its label primitive, such as `useFormatForAria`, plus a deprecated plain `formatForAria` export like `formatForDisplay`. `HotkeyManager.suspendCharacterKeys()` and a `suspendCharacterKeys` provider option suspend character key shortcuts for WCAG 2.1.4, and suspended hotkeys report `'suspended'`. Each framework has a new Accessibility guide.
- **Changes:** every framework skill gains an API table row for its ARIA formatter, which returns `undefined` while the hotkey can't fire, and says its plain `formatForAria` export is deprecated. The seven adapters with a provider list `suspendCharacterKeys` in the provider row and say it applies app-wide. `hotkeys-core` replaces the advice to pass `enabled` for WCAG 2.1.4 with `suspendCharacterKeys`, and gains rows for a hand-written `aria-keyshortcuts` value and a hand-written single-key off switch. `domain_map.yaml` and `skill_tree.yaml` are unchanged: no failure mode or scope decision moved.
- **Checks:** `packages/hotkeys/tests/format-aria.test.ts` and `character-keys.test.ts` cover the formatter and the suspension; the shared conformance suite covers each adapter's ARIA formatter and provider option; each adapter tests that its deprecated export is the core function. `intent validate` passes. Not run: fresh-consumer sessions.
1 change: 0 additions & 1 deletion _artifacts/skill_tree.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ skills:
- src/useHotkeys.ts
- src/HotkeysProvider.tsx
- src/useAppHotkeys.ts
- src/utils.ts
- TanStack/hotkeys:docs/framework/preact/quick-start.md
- TanStack/hotkeys:docs/framework/preact/guides/hotkeys-provider-and-scopes.md
requires:
Expand Down
2 changes: 1 addition & 1 deletion docs/agent-skills.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The packages you install determine which skills are available:
| `@tanstack/hotkeys` | `hotkeys-core`, `app-hotkeys` | Defaults versus raw `keydown` listeners, `enabled`, scopes, targets, sequences, testing, app hotkeys, and recording |
| `@tanstack/<framework>-hotkeys` | `<framework>-hotkeys` | Framework bindings (such as `useHotkey` or `createHotkey`), provider scopes, pitfalls, and wiring app hotkeys |

Framework skills ship for all 10 adapters (React, Preact, Solid, Angular, Vue, Svelte, Lit, Alpine, Ember, and Octane) under `node_modules/<package>/skills/<skill-name>/SKILL.md`. Task-specific guides live in `references/` and stay unloaded until needed, such as `references/scopes.md` for stacked dialogs.
Framework skills ship for every adapter (React, Preact, Solid, Angular, Vue, Svelte, Lit, Alpine, Ember, and Octane) under `node_modules/<package>/skills/<skill-name>/SKILL.md`. Task-specific guides live in `references/` and stay unloaded until needed, such as `references/scopes.md` for stacked dialogs.

## Step 1: Install TanStack Hotkeys

Expand Down
120 changes: 80 additions & 40 deletions docs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,6 @@
"label": "Sensible Defaults",
"to": "guides/sensible-defaults"
},
{
"label": "Formatting & Display",
"to": "framework/react/guides/formatting-display"
},
{
"label": "HotkeysProvider & Scopes",
"to": "framework/react/guides/hotkeys-provider-and-scopes"
Expand All @@ -171,10 +167,6 @@
"label": "Sensible Defaults",
"to": "guides/sensible-defaults"
},
{
"label": "Formatting & Display",
"to": "framework/preact/guides/formatting-display"
},
{
"label": "HotkeysProvider & Scopes",
"to": "framework/preact/guides/hotkeys-provider-and-scopes"
Expand All @@ -196,10 +188,6 @@
"label": "Sensible Defaults",
"to": "guides/sensible-defaults"
},
{
"label": "Formatting & Display",
"to": "framework/solid/guides/formatting-display"
},
{
"label": "HotkeysProvider & Scopes",
"to": "framework/solid/guides/hotkeys-provider-and-scopes"
Expand All @@ -221,10 +209,6 @@
"label": "Sensible Defaults",
"to": "guides/sensible-defaults"
},
{
"label": "Formatting & Display",
"to": "framework/angular/guides/formatting-display"
},
{
"label": "provideHotkeys & Scopes",
"to": "framework/angular/guides/provide-hotkeys-and-scopes"
Expand All @@ -246,10 +230,6 @@
"label": "Sensible Defaults",
"to": "guides/sensible-defaults"
},
{
"label": "Formatting & Display",
"to": "framework/vue/guides/formatting-display"
},
{
"label": "HotkeysProvider & Scopes",
"to": "framework/vue/guides/hotkeys-provider-and-scopes"
Expand All @@ -270,10 +250,6 @@
{
"label": "Sensible Defaults",
"to": "guides/sensible-defaults"
},
{
"label": "Formatting & Display",
"to": "framework/lit/guides/formatting-display"
}
]
},
Expand All @@ -292,10 +268,6 @@
"label": "Sensible Defaults",
"to": "guides/sensible-defaults"
},
{
"label": "Formatting & Display",
"to": "framework/svelte/guides/formatting-display"
},
{
"label": "HotkeysProvider & Scopes",
"to": "framework/svelte/guides/hotkeys-provider-and-scopes"
Expand All @@ -316,10 +288,6 @@
{
"label": "Sensible Defaults",
"to": "guides/sensible-defaults"
},
{
"label": "Formatting & Display",
"to": "framework/alpine/guides/formatting-display"
}
]
},
Expand All @@ -337,10 +305,6 @@
{
"label": "Sensible Defaults",
"to": "guides/sensible-defaults"
},
{
"label": "Formatting & Display",
"to": "framework/ember/guides/formatting-display"
}
]
},
Expand All @@ -359,10 +323,6 @@
"label": "Sensible Defaults",
"to": "guides/sensible-defaults"
},
{
"label": "Formatting & Display",
"to": "framework/octane/guides/formatting-display"
},
{
"label": "HotkeysProvider & Scopes",
"to": "framework/octane/guides/hotkeys-provider-and-scopes"
Expand All @@ -387,6 +347,10 @@
"label": "Hotkey Recording",
"to": "framework/react/guides/custom-hotkey-recording"
},
{
"label": "Formatting & Display",
"to": "framework/react/guides/formatting-display"
},
{
"label": "Cheat Sheets",
"to": "framework/react/guides/cheat-sheet-ui-helpers"
Expand All @@ -398,6 +362,10 @@
{
"label": "Held Keys",
"to": "framework/react/guides/held-key-state-helpers"
},
{
"label": "Accessibility",
"to": "framework/react/guides/accessibility"
}
]
},
Expand All @@ -412,6 +380,10 @@
"label": "Hotkey Recording",
"to": "framework/preact/guides/custom-hotkey-recording"
},
{
"label": "Formatting & Display",
"to": "framework/preact/guides/formatting-display"
},
{
"label": "Cheat Sheets",
"to": "framework/preact/guides/cheat-sheet-ui-helpers"
Expand All @@ -423,6 +395,10 @@
{
"label": "Held Keys",
"to": "framework/preact/guides/held-key-state-helpers"
},
{
"label": "Accessibility",
"to": "framework/preact/guides/accessibility"
}
]
},
Expand All @@ -437,6 +413,10 @@
"label": "Hotkey Recording",
"to": "framework/solid/guides/custom-hotkey-recording"
},
{
"label": "Formatting & Display",
"to": "framework/solid/guides/formatting-display"
},
{
"label": "Cheat Sheets",
"to": "framework/solid/guides/cheat-sheet-ui-helpers"
Expand All @@ -448,6 +428,10 @@
{
"label": "Held Keys",
"to": "framework/solid/guides/held-key-state-helpers"
},
{
"label": "Accessibility",
"to": "framework/solid/guides/accessibility"
}
]
},
Expand All @@ -462,6 +446,10 @@
"label": "Hotkey Recording",
"to": "framework/angular/guides/custom-hotkey-recording"
},
{
"label": "Formatting & Display",
"to": "framework/angular/guides/formatting-display"
},
{
"label": "Cheat Sheets",
"to": "framework/angular/guides/cheat-sheet-ui-helpers"
Expand All @@ -473,6 +461,10 @@
{
"label": "Held Keys",
"to": "framework/angular/guides/held-key-state-helpers"
},
{
"label": "Accessibility",
"to": "framework/angular/guides/accessibility"
}
]
},
Expand All @@ -487,6 +479,10 @@
"label": "Hotkey Recording",
"to": "framework/vue/guides/custom-hotkey-recording"
},
{
"label": "Formatting & Display",
"to": "framework/vue/guides/formatting-display"
},
{
"label": "Cheat Sheets",
"to": "framework/vue/guides/cheat-sheet-ui-helpers"
Expand All @@ -498,6 +494,10 @@
{
"label": "Held Keys",
"to": "framework/vue/guides/held-key-state-helpers"
},
{
"label": "Accessibility",
"to": "framework/vue/guides/accessibility"
}
]
},
Expand All @@ -512,6 +512,10 @@
"label": "Hotkey Recording",
"to": "framework/lit/guides/custom-hotkey-recording"
},
{
"label": "Formatting & Display",
"to": "framework/lit/guides/formatting-display"
},
{
"label": "Cheat Sheets",
"to": "framework/lit/guides/cheat-sheet-ui-helpers"
Expand All @@ -523,6 +527,10 @@
{
"label": "Held Keys",
"to": "framework/lit/guides/held-key-state-helpers"
},
{
"label": "Accessibility",
"to": "framework/lit/guides/accessibility"
}
]
},
Expand All @@ -537,6 +545,10 @@
"label": "Hotkey Recording",
"to": "framework/svelte/guides/custom-hotkey-recording"
},
{
"label": "Formatting & Display",
"to": "framework/svelte/guides/formatting-display"
},
{
"label": "Cheat Sheets",
"to": "framework/svelte/guides/cheat-sheet-ui-helpers"
Expand All @@ -548,6 +560,10 @@
{
"label": "Held Keys",
"to": "framework/svelte/guides/held-key-state-helpers"
},
{
"label": "Accessibility",
"to": "framework/svelte/guides/accessibility"
}
]
},
Expand All @@ -562,6 +578,10 @@
"label": "Hotkey Recording",
"to": "framework/alpine/guides/custom-hotkey-recording"
},
{
"label": "Formatting & Display",
"to": "framework/alpine/guides/formatting-display"
},
{
"label": "Cheat Sheets",
"to": "framework/alpine/guides/cheat-sheet-ui-helpers"
Expand All @@ -573,6 +593,10 @@
{
"label": "Held Keys",
"to": "framework/alpine/guides/held-key-state-helpers"
},
{
"label": "Accessibility",
"to": "framework/alpine/guides/accessibility"
}
]
},
Expand All @@ -587,6 +611,10 @@
"label": "Hotkey Recording",
"to": "framework/ember/guides/custom-hotkey-recording"
},
{
"label": "Formatting & Display",
"to": "framework/ember/guides/formatting-display"
},
{
"label": "Cheat Sheets",
"to": "framework/ember/guides/cheat-sheet-ui-helpers"
Expand All @@ -598,6 +626,10 @@
{
"label": "Held Keys",
"to": "framework/ember/guides/held-key-state-helpers"
},
{
"label": "Accessibility",
"to": "framework/ember/guides/accessibility"
}
]
},
Expand All @@ -612,6 +644,10 @@
"label": "Hotkey Recording",
"to": "framework/octane/guides/custom-hotkey-recording"
},
{
"label": "Formatting & Display",
"to": "framework/octane/guides/formatting-display"
},
{
"label": "Cheat Sheets",
"to": "framework/octane/guides/cheat-sheet-ui-helpers"
Expand All @@ -623,6 +659,10 @@
{
"label": "Held Keys",
"to": "framework/octane/guides/held-key-state-helpers"
},
{
"label": "Accessibility",
"to": "framework/octane/guides/accessibility"
}
]
}
Expand Down
Loading
Loading