Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
App-wide Keyboard Shortcuts
Status: In review
Date: 2026-09-07
Branch: feat/keyboard-shortcuts
Research: .ai/research/2026-09-07-keyboard-shortcuts.md
Proposal reviewed by user: .ai/scratch/keyboard-shortcuts-proposal.md
Summary
Carbon's Button now supports a shortcut prop (PR #1569: useShortcutKeys on react-hotkeys-hook, keycap badge, topmost-dialog guard), but only ~13 call sites use it. This spec rolls keyboard shortcuts out app-wide (ERP + MES): submit/confirm actions, list-page actions, detail-section navigation, module go-to, and a discoverability overlay — while consolidating the two competing shortcut systems into one.
mod = ⌘ on mac, Ctrl on Windows/Linux. All new user-facing copy is Lingui-translatable from day one.
Goals
- Every shared submit/confirm surface has a keyboard shortcut with a visible badge.
- One shortcut system (
useShortcutKeys); the legacyuseKeyboardShortcutshook is migrated and deleted. - Navigation: module go-to (ERP), sidebar go-to (MES), existing detail-tab shortcuts preserved on the new system.
- A
?help overlay lists the shortcuts active on the current page. - No regressions to existing shortcuts (⌘K, ⌘B, ⌘L,
n, ⌘⇧ tabs, Explorer add-line, MES clicker/wedge behavior).
Non-goals
- Bare-letter global shortcuts beyond the existing
n(collide with typing, scanners, Gantt's e/c/d). - Arrow-key table row navigation (collides with pagination ←/→ and Gantt; revisit later with hotkey scopes).
- Changes to Escape behavior (already handled by dialogs/ActionBar/Table).
- Shortcuts for academy/docs/starter apps.
- User-customizable bindings.
The shortcut map
Submit & common actions
| Shortcut | Action | Surface | Mechanism |
|---|---|---|---|
| ⌘Enter | Submit the form you're editing | All <Submit> buttons (287 ERP / 234 files, 10 MES), incl. all 62 ModalDrawer drawers |
packages/form Submit.tsx passes shortcut to Button by default; focus-aware guard (below) |
| ⌘Enter | Confirm | ConfirmDelete (181 sites) + Confirm modals |
shortcut on the confirm Button; topmost-dialog guard makes it win over any page form |
| n | New record | 57 list pages (New.tsx) |
migrate from legacy hook to Button shortcut="n" |
Navigation
| Shortcut | Action | Surface | Mechanism |
|---|---|---|---|
| ⌘K | Global search / go-to | ERP (existing) | unchanged |
| ⌘B | Toggle sidebar | all apps (existing) | unchanged; add the missing input-field guard in Sidebar.tsx |
| ⌘L | AI agent panel | ERP (existing) | unchanged |
| ⌘⇧ | Detail-page section tabs | DetailsTopbar/DetailSidebar (existing) | migrate to useShortcutKeys; fix the ⌘⇧P double-binding (Planning moves to ⌘⇧N, Purchasing keeps ⌘⇧P) |
| ⌘⇧L/A/P | Add line / attribute / parameter | 9 document Explorers (existing) | migrate as-is |
| ← / → | Prev/next table page | list pages (existing) | migrate as-is |
| g then | Go to ERP module | app-wide (ERP) | new sequence helper (below) |
| ⌥1–⌥7 | Go to MES sidebar page | MES app-wide | useShortcutKeys on AppSidebar links |
| ? (Shift+/) | Shortcut help overlay | ERP + MES app-wide | new registry + overlay (below) |
g-prefix module letters (bound to the stable module key, never position — order is per-user):
g a accounting · g d documents · g i inventory · g v invoicing · g t items (parts) · g o people · g r production · g p purchasing · g q quality · g u resources · g s sales · g e settings · g y users · g w workflows. (shopFloor is an external MES link — excluded.) Letters are tuneable at review; only reachable modules (permission-filtered via useModules()) are bound.
MES ⌥ digits: ⌥1 Operations · ⌥2 Assigned · ⌥3 Active · ⌥4 Recent · ⌥5 Jobs · ⌥6 Maintenance · ⌥7 Picking. (⌘digits are browser-reserved tab switching — not interceptable.)
MES actions
| Shortcut | Action | Surface |
|---|---|---|
| Space | Start/Pause the operation | JobOperation Controls.tsx Play/Pause button via Button shortcut="space" |
| Enter / Space / ← → | Step actions (existing) | AssemblyView — unchanged |
Space guards: inert in inputs (hook default), inert under open dialogs (Button guard), and must not double-bind on any screen that renders AssemblyView's own Space handler (separate routes today — operation.$operationId vs assembly.$operationId — verified during implementation).
Design
1. Submit shortcut in @carbon/form (packages/form/src/components/Submit.tsx)
Submitgainsshortcut?: ShortcutInput | ShortcutInput[] | false— defaultmod+enter,falseopts out. Forwarded toButtonwith a structured first binding{ key: "enter", modifiers: ["mod"], enabledOnInputElements: true }so it fires while typing in a field (react-hotkeys-hook disables form-tag events by default; Button doesn't pass this through today).- Focus-aware guard (composed with Button's dialog guard): detail pages render multiple
ValidatedFormcards, each with its ownSubmit; a naive default registers N handlers and clicks all N. Rule:- If
document.activeElementis inside a<form>: only theSubmitbelonging to that form fires. - If focus is in any other editable surface (a formless textarea like the agent chat input,
.ProseMirror, cmdk listbox, an open menu — the sharedisEditableTargetutil): no-op — those own their keys (lesson.ai/lessons.md:373). - If focus is on a non-editable element or body: fire only if this is the sole enabled Submit currently registered; ambiguity means no-op, never "all".
- Implemented via a module-level count of mounted active Submits in
@carbon/form, so rule 3 is O(1); each Submit's guard closure checks it.
- If
DefaultDisabledSubmitinherits (it rendersSubmit).- Badge: shown by default (⌘↵ keycap);
isLoading/isDisabledalready suppress/deactivate it. Sites whose Submit has arightIconkeep working — badge wins over rightIcon per Button's existing contract. - MES
Submits get this for free (same package).
2. Confirm modals
apps/erp/app/components/Modals/ConfirmDelete/ConfirmDelete.tsxandModals/Confirm/Confirm.tsx: addshortcut="mod+enter"to the confirm/destructiveButton. The topmost-dialog guard ensures only the modal's button fires while it is open — page Submits go inert automatically. Bare Enter deliberately not used (destructive; scanner wedge flushes on Enter).
3. ? help overlay (no runtime registry)
ShortcutHelpOverlaycomponent inpackages/react(a Modal listing shortcut rows grouped by section), bound toshift+/viauseShortcutKeys, mounted inapps/erp/app/routes/x+/_layout.tsxandapps/mes/app/routes/x+/_layout.tsx. Each app declares its entries, built exclusively from the central definition files — single-source by construction. Sequence entries (["g","s"]) render as chained keycaps. All copy via Lingui.- A dynamic runtime registry (hooks self-registering descriptions) was reviewed out as speculative — nothing would consume it; revisit only if per-page dynamic listing becomes a real need.
4. g sequence helper
- New
useShortcutSequence(prefix: "g", map: Record<string, () => void>)hook inpackages/react(react-hotkeys-hook has no sequence support): keydown listener; on bareg(no modifiers, not in input/contenteditable, no open dialog, not while wedge buffer active) arms for 1.5s; next matching letter navigates; any other key or timeout disarms. Escape disarms. Unit-tested likeuseShortcutKeys. - ERP: bound in
PrimaryNavigation.tsx(which already hasuseModules()and mounts SearchModal) using modulekey→navigate(to).
5. Legacy migration (delete useKeyboardShortcuts)
Migrate all 14 call sites to useShortcutKeys / Button shortcut:
New.tsx→Button shortcut="n"(drops manual ref-click +<Kbd>tooltip; standard badge).Pagination.tsx→useShortcutKeysfor ←/→ (IconButtons keep their Kbd hints or move to ShortcutKey).DetailsTopbar.tsx/DetailSidebar.tsx→ per-linkuseShortcutKeys; linkshortcutfields converted from legacy"Command+Shift+d"strings toShortcutInput("mod+shift+d"); tooltips render viaShortcutKey. Fix ⌘⇧P duplication acrossusePartNavigation,useMaterialNavigation,useConsumableNavigation,useToolNavigation(Planning → ⌘⇧N).- 9
*Explorer.tsxfiles →useShortcutKeyswith same combos;<Kbd>{prettifyShortcut(...)}hints →ShortcutKey. onboarding+/theme.tsx→useShortcutKeys(orButton shortcut="enter").- Then delete
packages/react/src/hooks/useKeyboardShortcuts.ts(+usePrettifyShortcutif no longer referenced) from the barrel.
Behavior notes: legacy fired single keys on key up; new fires on keydown — acceptable change. Legacy skipped inputs; new hook's defaults match.
6. Small fixes riding along
packages/react/src/Sidebar.tsx⌘B: route throughuseShortcutKeys(gains input guard + consistency) keeping the same combo.- MES
Controls.tsx:PlayButton/PauseButtongetshortcut="space"(ButtonWithTooltipmust forward the prop). - MES
AppSidebar.tsx: ⌥1–7 viauseShortcutKeysper link,ShortcutKeyhints in tooltips.
Design decisions
| Decision | Choice | Rationale |
|---|---|---|
| Single source of truth | All combos live in central definition files — packages/react/src/shortcuts.ts (shared: save, confirm, new, help, sidebar), apps/erp/app/shortcuts.ts (detail tabs, explorers, pagination, module go-to, search), apps/mes/app/shortcuts.ts (nav, start/stop). Components import named constants; no inline combo strings. All logic (hooks, registry, guards, badge, overlay) lives in packages/react only. |
User requirement — centralized, not scattered |
| Many-bindings-to-many-actions | New useShortcutKeyMap(map) helper in packages/react (one useHotkeys registration, dispatch by matched combo) replaces the legacy hook's Record<combo, fn> API for DetailsTopbar/DetailSidebar/Explorers/Pagination |
dynamic link arrays can't call a hook per item |
| Button API addition | optional shortcutGuard?: (e: KeyboardEvent) => boolean, AND-composed with the dialog guard |
lets Submit inject the focus-aware guard without duplicating Button's wiring |
| Plan approval gate | Execution starts only after the user approves the plan | User requirement (overrides ship-it auto-execute) |
| Submit combo | ⌘Enter only | User decision — leaves ⌘S to the browser; consistent "affirmative action" key |
| Confirm modal combo | ⌘Enter | User decision — deliberate two-key press for destructive actions; dialog guard resolves stacking with page forms |
| MES start/pause | Space | User decision — universal play/pause; guarded (inputs/dialogs) |
| Module go-to | g then letter |
User decision — Linear/GitHub pattern; scales to 15 modules; small sequence helper built once |
| MES nav | ⌥1–7 | User decision — ⌘digits are browser-reserved |
| Legacy hook | migrate all 14 sites, delete | User decision — one listener system; fixes ⌘⇧P dup, per-render re-registration |
| Help overlay | ? (shift+/), registry-based |
User decision — standard discoverability pattern |
| ⌘⇧P duplication fix | Planning → ⌘⇧N | free letter, "plaNning"; Purchasing keeps P (matches Suppliers/Customers pages) |
| Multiple Submits per page | focus-aware guard + sole-submit fallback | prevents N forms submitting at once; the actual bug a naive default would ship |
| Shortcut display | Button's built-in ShortcutKey badge |
already shipped; consistent; replaces ad-hoc <Kbd> hints as sites migrate |
| Enter (bare) for submit | rejected | wedge flushes scans on Enter; MES clicker owns Enter; react-aria fields swallow it |
| Scopes/priority system (HotkeysProvider) | not now | YAGNI — dialog guard + focus guard + no-arrow-rowNav avoids the need; revisit if collisions appear |
Acceptance criteria
- In any ERP create/edit drawer (e.g. New Customer), typing in a field and pressing ⌘Enter submits the form; the Submit button shows a ⌘↵ badge.
- On a detail page with multiple form cards (e.g. Part → Details), ⌘Enter submits only the card containing focus; with focus on the page body and multiple forms present, nothing happens; with focus in a formless editable (the agent chat textarea), nothing happens.
- With a ConfirmDelete modal open above an edit form, ⌘Enter triggers only the delete; Escape still closes.
non a list page opens the New form exactly as before, badge rendered by Button, and no legacy listener remains (useKeyboardShortcutsfile deleted, grep returns nothing).- On a Part detail page, ⌘⇧P goes to Purchasing and ⌘⇧N goes to Planning (both reachable — the old silent overwrite is gone).
gthensfrom any ERP page navigates to Sales;gwhile typing in an input does nothing;gwith a modal open does nothing.?opens the help overlay listing (at minimum) the global shortcuts and any page-registered ones, fully translated; Escape closes it.- MES: Space toggles Start/Pause on the operation screen; Space inside a quantity input does not; ⌥3 navigates to Active.
- Existing behavior unchanged: ⌘K search, ⌘B sidebar, ⌘L agent, table pagination ←/→, Gantt e/c/d/arrows, AssemblyView Enter/Space/←/→, barcode wedge navigation.
pnpm exec turbo run typecheck --filter=@carbon/react --filter=@carbon/form --filter=erp --filter=mespasses;useShortcutKeysunit tests extended for sequence helper + registry.
Phases (≤5, detailed in the plan)
- Infrastructure (
packages/react,packages/form): registry +description, sequence hook, Submitshortcutprop + focus-aware guard, Sidebar ⌘B guard, tests. - Submit & confirm rollout: Submit default ⌘Enter (ERP+MES), ConfirmDelete/Confirm ⌘Enter, audit odd Submits (rightIcon, portal cases).
- Legacy migration: New, Pagination, DetailsTopbar/DetailSidebar (+⌘⇧P fix), 9 Explorers, onboarding theme; delete legacy hook.
- ERP navigation & discoverability: g-prefix module go-to,
?help overlay + static entries, i18n. - MES: Space start/pause, ⌥1–7 sidebar nav, MES help overlay; final sweep (translations, self-review, browser smoke test).
Autonomous decisions (execution, 2026-09-07)
User enabled autonomous execution. Calls made without asking, worth review first:
- Test approach changed (review-worthy): the repo has no DOM test environment (vitest env
node, no jsdom) — instead of adding a jsdom dev dependency, the risky logic was extracted into pure, node-testable cores:shouldSubmitOnShortcut(Submit guard truth table,packages/form/src/internal/submitShortcutRegistry.ts),sequenceStep(g-prefix state machine),matchesShortcut(combo matcher). 76 tests green. - Detail-tab constants corrected to real semantics (review-worthy): the spec's guessed names (quoting/manufacturing/terms/documents) didn't match the code — actual tabs are Quality=⌘⇧Q, Sales(items)=⌘⇧X, Payment=⌘⇧P, Tax=⌘⇧T, Shipping=⌘⇧S, Processes=⌘⇧R, Activity=⌘⇧A. All combos unchanged from what users had (except the Planning fix ⌘⇧P→⌘⇧N as spec'd).
- Duplicate-combo warning fires in all environments (packages/react has no
process.envtyping; a duplicate is a bug worth surfacing in prod consoles too). matchesShortcutgained anevent.codefallback for named punctuation (slash/period/comma/minus/equal) so?(shift+/) matches for the help overlay.ONBOARDING_SHORTCUTS.continueandMODULE_GO_TO_PREFIXconstants added (centralization consistency); the Settings module is included in g-go-to viauseSettingsModule().New.tsxtooltip removed — the inline keycap badge replaces it (Gantt precedent).- Pagination's condensed IconButtons now receive the shortcut refs — the legacy binding only clicked the non-condensed buttons (small behavior improvement).
- MES
ButtonWithTooltip/PlayButton/PauseButtonconverted toforwardRef(needed for the Space ref-click). usePrettifyShortcutdeleted along with the legacy hook (unreferenced after migration — the plan made this conditional).- MES help overlay lists AssemblyView's Enter/Space/←/→ as display-only rows; the bindings stay owned by AssemblyView.
Open questions (resolved)
- Submit shortcut — Answer: ⌘Enter only (user; ⌘S rejected).
- Confirm/delete modals — Answer: ⌘Enter (user).
- MES start/pause — Answer: Space (user).
- Optional scope — Answer: all four in: legacy migration,
?overlay, MES nav keys, ERP module go-to (user). - ERP module go-to mechanism — Answer:
gthen letter sequences (user; ⌘digits browser-reserved). - MES nav keys — Answer: ⌥1–7 (user; replaces reserved ⌘1–7).
Changelog
- 2026-09-07: Spec written after research (3 codebase surveys) and user interview; all questions resolved.
- 2026-09-07: Thermo-nuclear plan review (
.ai/reviews/2026-09-07-keyboard-shortcuts-plan-review.md) folded in: refined Submit guard (formless editables), entries-arrayuseShortcutKeyMapwith dev duplicate warning, sharedisEditableTarget, runtime registry cut as speculative, alt+digitevent.codematching built in.
Design revision (2026-09-07, user review round 1)
User review found the first pass mechanically applied ⌘Enter + visible badges everywhere with no interaction design. Reworked under these principles (now codified in .claude/rules/conventions-ui.md § Keyboard shortcuts):
- Enter vs ⌘Enter is a per-screen design decision: Enter for one-obvious-action screens (single input → native form submit; choice screens → select-and-continue); ⌘Enter only for real multi-field forms where Enter has other meanings.
- Badge visibility ≠ binding: login (erp+mes), OTP screens (mfa/unlock/SessionLockOverlay ×2, auto-submit at 6 digits) and the 10 single-text-input dialogs (
*TypeForm/*StatusForm/ScrapReason/NoQuoteReason/StorageType/ChangeNoticeType/ReviewersList) keep the silent binding but drop the ⌘↵ badge (hideShortcutKey). Textarea/editor forms (Suggestion, RichText notes, UnscrapModal) keep the badge — Enter means newline there, so ⌘Enter is the legitimate advertised submit. - Choice screens got real semantics + focus management: onboarding theme mode + swatches converted from N plain Buttons to Radix radio groups via new
RadioGroupButton(packages/react/src/Radio.tsx — barrel export extended, "ask first" waived under autonomous refactor mandate);ChoiceCardGroupgained anautoFocusprop (focus selected card on mount); industry sub-screens A/B use it; both Next buttons + theme Next + import "Create company" carryONBOARDING_SHORTCUTS.continue(Enter, ↵ badge) — replacing theme.tsx's hand-wired invisibleuseShortcutKeyMapEnter. Radix radios don't activate on Enter, which is what leaves Enter free to mean "continue". Initial focus added: login email, OTP inputs (InputOTP gainedautoFocusprop), magic-link CTA, invite Join CTA; import-upload dropzone got a visible focus ring. - react-hotkeys-hook is the only matcher:
useShortcutKeyMapno longer hand-rolls a document listener +matchesShortcut— it delegates touseHotkeys(v4.5.1 matchesevent.keyAND mappedevent.code, so ⌥1→"¡", ⌥letter, shift+/ all work natively), dispatching entries bycanonicalCombo(mirrors the library's internalmapKey; pinned by tests).matchesShortcutdeleted (autonomous decision #1/#4 partially superseded).useShortcutSequencestays hand-rolled — the library has no sequence support (documented exception). - Left as-is deliberately: plan.tsx (multiple independent CTAs, no single obvious action), Gantt's pre-existing inline shortcut literals + raw
useHotkeys(pre-dates this work), MES AssemblyView/Step "enter" literals (pre-existing bindings), verify.tsx's no-submit-button form quirk.