rtivital / omatsuri

PWA with 12 open source frontend focused tools
https://omatsuri.app
MIT License
2.54k stars 201 forks source link

Keyboard events not updated correctly with AZERTY keyboard #17

Closed maxime-louf closed 2 years ago

maxime-louf commented 2 years ago

Hello, using the "Keyboard events code" app, event.code doesn't return the correct response with an AZERTY keyboard. For example, pressing letter 'A' return event.code 'keyQ' instead of 'keyA'. Same when pressing 'Z' and so on. However event.key return the correct key. Thank you

rtivital commented 2 years ago

That's how browser handles keyboard events, there is not much we can do on our side https://github.com/rtivital/omatsuri/blob/master/src/apps/events-keycode/generate-event-data.js

maxime-louf commented 2 years ago

Oh you're right. So i feel like event.code shouldn't be used since it's response can't be properly anticipated and event.key should be preferred.

rtivital commented 2 years ago

event.key cannot be used as well, it represents a pressed character, not key, for example, you will get E value for English keyboard and У (Russian letter) for Russian

maxime-louf commented 2 years ago

Fair enough, closing this issue.