Repository navigation
fix: let modifier shortcuts through on the preview page - #70
Merged
blixvip merged 2 commits intoNov 15, 2026
Merged
Conversation
Alt+Left and Cmd+Left (the browser's Back) were swallowed, and Alt+Right, Ctrl+Home and Ctrl+End were hijacked the same way: the page's keydown handler matched ArrowLeft/ArrowRight, Home/End, Space and the frame-step keys without looking at modifier state, then called preventDefault. Return early when Alt, Ctrl or Cmd is held, before any bare key is handled, so those combinations stay with the browser.
…s-pass-through # Conflicts: # public/demo.mjs
Owner
|
Thanks for the fix! It overlapped with a PR merged just before it, so I merged main into your branch (tests pass) and am merging now. 🙏 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On the preview page,
Alt+Left(browser Back on Windows and Linux) andCmd+Left(Back on macOS) jumped to the previous section instead of navigating back, andAlt+Right,Ctrl+HomeandCtrl+Endwere hijacked the same way. The page's shortcuts take over keys the browser uses.Root cause
The
keydownhandler inpublic/demo.mjsmatchesevent.code === 'ArrowLeft'/'ArrowRight',Home/End,Spaceand the frame-step keys without ever looking at modifier state, and callsevent.preventDefault()for each of them.Fix
Return early from the handler when
event.altKey || event.ctrlKey || event.metaKeyis set, before any bare key is handled, so combinations stay with the browser. BareArrowLeft/ArrowRight,Home/End,Spaceand the frame-step keys behave as before.Testing
test/browser-shortcut-keys.test.jsparsespublic/demo.mjsand asserts the modifier guard sits inside thekeydownhandler and before the first bare-key branch. It fails on the previous commit and passes with the fix.npm test: 27 pass, 2 skipped (one is the new test),npm run checkclean.Fixes #67