zer0bin-dev / zer0bin

🖊️ // Just a place to paste
https://zer0b.in
MIT License
93 stars 8 forks source link

Keybinds don't work when using different keyboard layout 🐛 #68

Closed hatkidchan closed 1 year ago

hatkidchan commented 1 year ago

💡 Summary

When pressing, say, Ctrl+S when using locale different from English (say, russian), default browser behavior is triggered.

🥰 Expected Behavior

They handled properly

🤬 Actual Behavior

It's not handled at all

📝 Steps to Reproduce

  1. Have a different layout
  2. Press Ctrl+S
  3. It doesn't work

📌 Environment

zer0bin version: The one that's on https://stepbro.voring.me Your OS: Arch Linux Your browser: Firefox

:notebook: Notes

In keydown even handler (or, more specifically, in KeyboardEvent), key property contains letter, corresponding to the current layout, which doesn't make any sense for keyboard shortcuts. In case of russian layout, pressing Ctrl+S would look like pressing Ctrl+Ы, and since there's no shortcut for that, event is not being cancelled and browser handles it instead. Possible fix would be to replace event.key with event.code and replace corresponding checks (e.key == "s" -> e.code == "KeyS")