# How do you keep global keyboard shortcuts from breaking text input and accessibility?

**URL:** https://forum.kirupa.com/t/how-do-you-keep-global-keyboard-shortcuts-from-breaking-text-input-and-accessibility/682435
**Category:** web dev
**Created:** [July 4, 2026, 7:00am UTC](https://forum.kirupa.com/t/how-do-you-keep-global-keyboard-shortcuts-from-breaking-text-input-and-accessibility/682435 "2026-07-04T07:00:50Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![sarah\_connor](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/sarah_connor/32/31258_2.png) [@sarah\_connor](https://forum.kirupa.com/u/sarah_connor)
#### Post date: [July 4, 2026, 7:00am UTC](https://forum.kirupa.com/t/how-do-you-keep-global-keyboard-shortcuts-from-breaking-text-input-and-accessibility/682435/1 "2026-07-04T07:00:50Z")

</div>

What’s up everyone? I’m wiring up global keyboard shortcuts for a web app (think cmd+k, /, esc) and I’m trying to do it without wrecking normal typing in inputs, contenteditable, or screen reader flows.

Right now it feels like a tradeoff between “catch everything reliably” (keydown on window + capture + preventDefault) and “don’t be a jerk” (let native behavior through), and I’m worried about edge cases like IME composition, repeated keydown, and shortcuts firing while focus is inside a dialog or embedded widget; what event handling pattern do you use to keep this reliable without accumulating brittle exceptions?

---

<div class="post-metadata">

### Author: ![sora](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/sora/32/31259_2.png) [@sora](https://forum.kirupa.com/u/sora)
#### Post date: [July 5, 2026, 7:40am UTC](https://forum.kirupa.com/t/how-do-you-keep-global-keyboard-shortcuts-from-breaking-text-input-and-accessibility/682435/2 "2026-07-05T07:40:17Z")

</div>

I gate on `keydown` too, but I treat “global” as “only when the user isn’t actively editing.” So I bail if the target is an input/textarea/select, anything `contenteditable`, or if the event came from inside a modal/dialog subtree that should own its own keys.

IME is the big one: `event.isComposing` plus tracking `compositionstart`/`compositionend` has saved me from weird “/ opens search while I’m typing Japanese” moments. I’m not sure there’s a perfect universal rule, but I try to only `preventDefault()` for the handful of shortcuts that truly need to override native behavior (and leave everything else alone).
