-
-
Notifications
You must be signed in to change notification settings - Fork 3k
fix(keymap): prevent tilde key from highlighting entire keymap (@LodunCoombs) #7128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Miodec
merged 4 commits into
monkeytypegame:master
from
LodunCoombs:fix/keymap-tilde-bug
Nov 26, 2025
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
9a9a540
fix: prevent tilde key from highlighting entire keymap
LodunCoombs 101f4b4
fix(keymap): handle key finding edge cases with performant CSS selectors
LodunCoombs 1ba24a9
refactor(keymap): use native selectors for performance
LodunCoombs 3257d84
fix(keymap): change delimiter to private unicode char and simplify se…
LodunCoombs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fix is not flashing/highlighting the
~key anymore.extracting the findKeyElements is a good idea. What about keeping the selector and just add a special handling the tilde key ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thank you for the review and the feedback!
I did some extra testing on my end, and the
~key appears to be flashing correctly. I tested this by finding a visible key in DevTools (like the "K" key) and changing itsdata-keyattribute to`~~~. When I pressed the tilde key, it lit up as expected.The
findKeyElementsfunction handles this because"~~~".split('~~')correctly produces the array ['`', '~'], and .includes(char) returns true, which returns the correct element.The main reason I chose this
.filter()approach over adding a special case for the tilde was to create a more robust solution. It prevents the original bug (where the*=selector matched the~~delimiter itself) and also handles other special characters like"without needing moreifstatements in the future.Could you let me know if you're seeing different behavior, or if there's a specific test case I might have missed? Happy to make changes if so!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I modified the qwerty layout and replaced
;with~resulting in
I am testing with chrome.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that the filter is the more robust solution, but it seems to bit quite a bit slower.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, thank you for spotting that! I just pushed a new commit that should address the issues. It uses a combined CSS selector, which handles all edge cases, including when the
data-keyis~~~:. And, the performance should be much faster using the native CSS selectors. Let me know what you think!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New approach seems even slower
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the code to follow your approach (special handling for
"and~).I added one small tweak to the tilde selector:
[data-key*="~~~"], [data-key="~"]. The second part handles the theoretical edge case where a key is mapped only to~(no delimiter). What do you think?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @LodunCoombs ,
thanks for the change. I noticed another problem within the
updateLegendsfunction. I had a talk with @Miodec. We think the easiest fix for now would be to change the delimiter from~~toprivate use unicode character.Please keep the extracted
findKeyElementsbut remove the additional check for the tilde key.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea!
I've updated
keyDataDelimiterto\uE000and removed the special tilde handling fromfindKeyElements. What do you think?