Make key filters work on non-latin keyboard layouts#869
Open
psd-coder wants to merge 1 commit intohotwired:mainfrom
Open
Make key filters work on non-latin keyboard layouts#869psd-coder wants to merge 1 commit intohotwired:mainfrom
psd-coder wants to merge 1 commit intohotwired:mainfrom
Conversation
Key filters matched event.key only, so keydown.j failed on non-latin layouts. Fallback to event.code for non-ASCII keys and add regression tests.
|
I want to bring more attention to this issue. Right now, hotkeys are not working in 50% cases for all US-speaking users. For instance, in Fizzy it means that user can’t trust hotkey and stop using them. |
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.
Overview
Fixes key filter matching in Stimulus actions so that keyboard shortcuts defined with ASCII characters (e.g.,
keydown.j) work correctly when the user's active keyboard layout produces non-ASCII characters (Cyrillic, Greek, Hebrew, etc.).Problem Statement
When users have a non-latin keyboard layout active (e.g., Russian phonetic, Greek, Hebrew),
event.keycontains the non-ASCII character produced by their layout rather than the Latin letter on the physical key. This caused key filters likekeydown.j->controller#actionto never match, making keyboard shortcuts unusable for non-latin keyboard users.Solution Approach
normalizedKeyboardEventKey()that falls back to deriving the key fromevent.codewhen the mapped filter key is a printable ASCII character butevent.keyis notevent.code(e.g.,KeyJ→j,Digit3→3) so physical key position is used instead of the produced characterevent.isComposing) to avoid interfering with input method editorsBreaking Changes
None.
Testing