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

fix: some shortcuts not working on different langs #4140

Merged
merged 2 commits into from
Sep 18, 2024

Conversation

WofWca
Copy link
Collaborator

@WofWca WofWca commented Sep 17, 2024

Different keyboard layouts (e.g. Russian).
event.key gives you the printed character and not the key code.
If the language doesn't use latin letters, you'll never get
Ctrl + N or Ctrl + K to work.

This behavior aligns with e.g. Telegram, and browsers (Ctrl + W).

There is a side-effect, however. The shortcuts cheat-sheet
shows which buttons you're currently pressing, and now it diverges
from actual behavior.
E.g. if you actually press the key with the code "Comma",
it won't show you this for the Russian language where the key
to print a comma is different.
See KeyboardShortcutHint.tsx.

I think this can be fixed later, especially that it's already buggy:
it won't show you that you're pressing "N" because
you'd actually need to press "Shift+N", otherwise you get "n".

@WofWca WofWca force-pushed the wofwca/fix-shortcuts-on-different-layouts branch from fe43c36 to 3379996 Compare September 17, 2024 14:55
@WofWca WofWca marked this pull request as ready for review September 17, 2024 14:55
Different keyboard layouts (e.g. Russian).
`event.key` gives you the printed character and not the key code.
If the language doesn't use latin letters, you'll never get
Ctrl + N or Ctrl + K to work.

This behavior aligns with e.g. Telegram, and browsers (Ctrl + W).

There is a side-effect, however. The shortcuts cheat-sheet
shows which buttons you're currently pressing, and now it diverges
from actual behavior.
E.g. if you actually press the key with the code "Comma",
it won't show you this for the Russian language where the key
to print a comma is different.
See `KeyboardShortcutHint.tsx`.

I think this can be fixed later, especially that it's already buggy:
it won't show you that you're pressing "N" because
you'd actually need to press "Shift+N", otherwise you get "n".
...wherever applicable.

About `key.toLowerCase()`: it appears that it was unnecessary.
@WofWca WofWca force-pushed the wofwca/fix-shortcuts-on-different-layouts branch from 3379996 to fc07333 Compare September 18, 2024 06:46
@WofWca WofWca merged commit 23a0791 into main Sep 18, 2024
8 checks passed
@WofWca WofWca deleted the wofwca/fix-shortcuts-on-different-layouts branch September 18, 2024 06:51
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

Successfully merging this pull request may close these issues.

2 participants