Repository navigation
fix(opposite-shift): shift stuck when both shifts are held (@TharunBabu-05) - #8431
Open
TharunBabu-05 wants to merge 1 commit into
Open
TharunBabu-05 wants to merge 1 commit into
TharunBabu-05 wants to merge 1 commit into
Conversation
…bu-05) On Windows, holding both shift keys only fires keyup for the last one released, so the other stays marked as held and opposite shift mode rejects normal key presses until that shift is pressed again. - resync left/right shift from event.shiftKey on every key event - track modifiers in the capture phase so the state is updated before the input keydown handler reads it Fixes monkeytypegame#8386 Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Description
Fixes a problem with Opposite Shift Mode, where the Shift key state could get stuck when pressing both Shift keys one after another and then releasing them.## Repro Steps (Windows)
Steps to reproduce (Windows)
o,p, orl.Root cause
If you hold both shift keys down simultaneously in Windows, then release the first one, you may not get a key-release event for it while the other shift key is held down.
That is , the Shift key pressed earlier can still be marked as held in the internal state of the application .
This stale state can result in subsequent lowercase characters being treated as if the Shift key were still held down, even when both Shift keys have been released.
Fix
Updated the keyboard event handling to clear the internal Shift-key state when the browser reports that no Shift key is currently held (
e.shiftKey === false).The capture phase updates the Shift-key state through listeners. This makes sure that the Shift-key state is cleared before the Opposite Shift Mode check.
This ensures that:
Known limitation
While one Shift key is still held, the other Shift key may remain marked as held internally because Windows does not provide a key-release event for the first Shift key in this specific sequence.
The internal state is corrected once the browser reports that no Shift key is held.
Testing
Tested on Windows with Opposite Shift Mode enabled.
Manual testing
Confirmed the following cases:
o,p, andlafter both Shift keys are released.Unit tests
Added:
Path: frontend/tests/states/modifiers.spec.ts
→ 4 of the 5 tests fail on master
"All tests pass with the fix" → "all 5 pass with the fix"
Checks
Closes #8386