Skip to content
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

The map should always identify digit keys as 0-9, even if the layout requires Shift to type the digit #31

Open
tszynalski opened this issue Nov 22, 2019 · 0 comments

Comments

@tszynalski
Copy link

KeyboardEvent.get() returns the key which would be typed if the current physical key were pressed with no modifiers.

On some layouts, numeric keys (0-9) type national or punctuation characters instead, and the digits must be accessed by holding Shift. For example, on AZERTY, [Digit3] types " (double quote). To type 3, you have to press Shift+[Digit3], or have CapsLock on.

I propose the following exception:

On layouts on which numeric keys (0-9) require Shift to type digits (examples: AZERTY, Czech QWERTZ, Lithuanian), .get() should always return the digit.

On such locales, shortcuts which use [Digit0] - [Digit9] are generally referred to using the digit, even if the digit is not the "base" (unmodified) key. I'm sure French or Czech users would find it strange to see shortcuts referred to as Ctrl+( (AZERTY 5), ' (AZERTY 4) or Alt++ (Czech 1).

Here are examples of Microsoft's Windows shortcut cheatsheets for French and Czech. Notice it says "Touche de logo Windows + numéro" and "Ctrl+1" (WordPad section).

https://support.microsoft.com/fr-fr/help/12445/windows-keyboard-shortcuts
https://support.microsoft.com/cs-cz/help/12445/windows-keyboard-shortcuts

PS. In my Web app, I have some commands bound to Alt+1, Alt+2, etc. and it would be easier if KeyboardMap.get() returned the digit in such cases, rather than the unmodified key. Right now the workaround is to compare KeyboardMap.get("Digit1") with "1" to detect such layouts and fall back to using KeyboardEvent.code. Can't just use .code all the time, because there are actually layouts where the digits on keycaps don't match KeyboardEvent.code.

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

No branches or pull requests

1 participant