Summary#
HotkeyManager has no way to register a hotkey in the capture phase. Its internal #ensureListenersForTarget always calls:
addEventListener('keydown', handler)
addEventListener('keyup', handler)
with no third argument, so every registration listens in the bubble phase, and HotkeyOptions exposes no capture option to opt out of that.
Why this matters#
This comes up whenever another library or the host page has its own keydown handler that calls preventDefault() / stopPropagation() before the event reaches a bubble-phase listener higher up the tree.
That's a common pattern for widget libraries managing their own keyboard navigation (tab strips, grids, menus) which don't inspect modifiers before acting on a bare key. A consumer needs capture-phase listening specifically to claim a modified stroke (e.g. Mod+Shift+Enter) before such a handler mistakes it for an unmodified one (e.g. bare Enter) and swallows it.
Suggested fix#
Add an optional capture to HotkeyOptions, defaulting to false so current behavior is preserved:
interface HotkeyOptions {
capture?: boolean;
}
Thread it into the addEventListener / removeEventListener calls in #ensureListenersForTarget / #removeListenersForTarget.
Since a single target might have both capture and bubble registrations, the internal per-target listener/registration bookkeeping needs to be keyed by (target, phase) rather than just target.
Happy to open a PR with this fix plus tests if that's useful — implemented and verified against v0.9.0 locally.
Closed as not relevant currently.