Troubleshooting
Grouped by symptom. Most failures are silent; check attribution, provider order, and layer state first.
Diagnostic order
- Provider nesting.
- The owner is active: screen in the stack, layer open, element
active. - Focus:
focusCurrent()and the group's active target. - Modal barrier or
allowModal. mode,when, and named conditions.- Exact-key vs wildcard ordering.
Most "keys do nothing" reports resolve at step 1 or 2.
A key does nothing
| Possible cause | Check |
|---|---|
| Provider nesting reversed | KeyboardProvider must nest inside ScenarioManagementProvider |
| Owner inactive | The screen is in the stack, the layer is open, the element is active |
| Gated | Check mode, when, and whether a named condition is registered |
| Focus elsewhere | Only the active focus target's bindings match; confirm with focusCurrent() |
| Modal barrier | Unhandled keys are swallowed; use allowModal |
stopsWorkingAfterLayerAppearing | Page bindings are dormant while any layer is open |
Exact key wins over '*' | Call enableWildcardPriority() when the wildcard must run first |
Ghost keys
Bindings from a screen you left still fire: the binding was registered in useEffect without returning the unbind function. Return it, or call it manually.
Focus
- Target disappears after unbinding: with
releaseFocusWhenEmpty, the last unbind removes it; re-register the samefocusIdto recreate it. focusSetreturnsfalse: the target is created lazily; register a binding with thatfocusIdfirst.- Named group does not respond: the group's first target is auto-activated; call
activateFocusGrouponly when the group was emptied bykickFocusGroup.autoTabrotates the default group only.
Layers
- Nothing appears after opening:
openLayercreates an empty container; mount elements withapplyElement. - Layer is gone after navigation:
crossPagedefaults tofalse. - A cross-page layer steals keys: scope it with
automaticTakeoverKeyboard. bringLayerToFrontdoes nothing: it only affects regular layers; modal and unknown IDs are ignored with a warning.penetrationis not blocking: it releases keys; usestopto block.
Mouse
- Region does not respond: check
<KeyboardProvider mouse>, TTY streams, the ref attached to the Box, and that the Box is not 0×0. - Click does not move focus:
useMouseRegionandboundKeyboardmust receive the same object ref; a callback ref fails silently. onDragMovestops: the drag target is captured at press, so it should not stop; check whether the component unmounted mid-drag.- Overlapping regions pick the wrong one: raise the child control's
priority.
Composition and sequences
- A chain is not undoable: only timeouts,
isEndKey, andexecutereturningnullrecord it; an unmatched key drops the chain. - Undo throws: the request exceeds the buffer; query
bufferedCompositionCount()first. - A sequence does not fire: check
timeout, mismatched keys (exclusive), and whether the focus target is active.
Common error messages
| Message | Cause |
|---|---|
[ink-cartridge] No KeyboardEngine is mounted. …getEngine()… | A module-level API call with no KeyboardProvider |
[ink-cartridge] Condition "<id>" is not registered. … | A named condition was never registered |
[keyboard-engine] <fn>() must be called inside a screen component or overlay. | An owner-scoped method with no owner |
… declared in globalKeys with cover: false, so overriding is not allowed. | Overriding a cover: false global key |
Cannot undo N sequence(s): only M buffered. | Undo exceeds the buffer |
[ink-cartridge] Mouse tracking requires a TTY input stream … | Mouse enabled without a TTY |
Testing
- Escape (
\x1b) is unreliable withink-testing-library. - Effects settle after
flush()(about 50ms). - Use
clearRegistry()inbeforeEachfor isolation.
TypeScript
useRef<<T>in TSX parses as JSX; writeuseRef<T>.
