Repository navigation
Conversation
Browsers name the Cmd and Windows keys `MetaLeft` and `MetaRight`, and gl.js only knew their old names, `OSLeft` and `OSRight`, which Firefox dropped in version 118, so `KeyCode::LeftSuper` never went down and key events never held `KeyMods::logo`: Cmd+Z reached an app as Z. Both names now map to Super, and `metaKey` sets the logo modifier. macOS browsers send no keyup for a key released while Cmd is down, so after Cmd+Z, Z stayed down until it was pressed again. Every key but the modifiers now comes up with Cmd. A canvas that loses focus gets none of its keys' keyups either, as when Cmd+Tab switches apps, so they all come up with its focus. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Why
On the web, Cmd (and the Windows key) never reached an app. Browsers name it
MetaLeftandMetaRightinKeyboardEvent.code, andinto_sapp_keycodeonly knewOSLeftandOSRight, the names Firefox used before version 118. SoKeyCode::LeftSupernever went down, key events never heldKeyMods::logo, and Cmd+Z reached an app as a plain Z, after an "Unsupported keyboard key" log for Cmd.macOS browsers also send no
keyupfor a key released while Cmd is down, so after Cmd+Z,is_key_down(KeyCode::Z)stayed true until Z was pressed again. A canvas that loses focus with keys down, as when Cmd+Tab switches apps, never hears theirkeyupeither.Change
MetaLeftandOSLeftmap toLeftSuper, andMetaRightandOSRighttoRightSuper.metaKeysetsSAPP_MODIFIER_SUPER, throughinto_sapp_modifiers, whichkeydownandkeyupnow share.Verification
In a macroquad game (CHOMP) built for the web, through Playwright on macOS, in Chromium and WebKit:
key_down(Z, 0)key_down(LeftSuper, SUPER),key_down(Z, SUPER)The game's Cmd+Z, Cmd+Shift+Z and Cmd+R (undo, redo, restart) work with it, and Ctrl+Z still does. Playwright's Firefox doesn't start on this Mac, so Firefox wasn't run. Playwright sends its own key events, so the missing
keyupwas stood in for by never releasing Z before Cmd.🤖 Generated with Claude Code