Skip to content

fix: let modifier shortcuts through on the preview page - #70

Merged
blixvip merged 2 commits into
blixvip:mainfrom
bfs2021:fix/modifier-shortcuts-pass-through
Nov 15, 2026
Merged

blixvip merged 2 commits into
blixvip:mainfrom
bfs2021:fix/modifier-shortcuts-pass-through

Conversation

@bfs2021

@bfs2021 bfs2021 commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Problem

On the preview page, Alt+Left (browser Back on Windows and Linux) and Cmd+Left (Back on macOS) jumped to the previous section instead of navigating back, and Alt+Right, Ctrl+Home and Ctrl+End were hijacked the same way. The page's shortcuts take over keys the browser uses.

Root cause

The keydown handler in public/demo.mjs matches event.code === 'ArrowLeft' / 'ArrowRight', Home / End, Space and the frame-step keys without ever looking at modifier state, and calls event.preventDefault() for each of them.

Fix

Return early from the handler when event.altKey || event.ctrlKey || event.metaKey is set, before any bare key is handled, so combinations stay with the browser. Bare ArrowLeft/ArrowRight, Home/End, Space and the frame-step keys behave as before.

Testing

  • New test/browser-shortcut-keys.test.js parses public/demo.mjs and asserts the modifier guard sits inside the keydown handler 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 check clean.
  • Not manually checked in a browser from this machine: the guard is the only change to the handler, and the branches below it are untouched.

Fixes #67

bfs2021 and others added 2 commits November 15, 2026 04:59
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
@blixvip

blixvip commented Nov 15, 2026

Copy link
Copy Markdown
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. 🙏

@blixvip
blixvip merged commit 83bc1d1 into blixvip:main Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Let browser shortcuts with Alt, Ctrl or Cmd pass through the preview page

2 participants