ruffle
ruffle copied to clipboard
Problem with Key.getCode on AZERTY keyboard: the layout is always QWERTY on Ruffle
Describe the bug
On AZERTY keyboard, pressing the A key should give the code 65. Instead, it gives the code 81 of the Q letter (QWERTY). On Ruffle web version, the layout is always QWERTY. On Ruffle desktop, and Flash Player, it works normally.
I made a simple test to try it out: https://www.txori.com/stuff/ruffle/keycode_azerty.php
Expected behavior
Pressing A on AZERTY should retrieve the A Key.getCode And that goes for every keyboard layouts.
Affected platform
Self-hosted version
Operating system
Windows 10
Browser
Chrome 97
Additional information
No response
Thank you for pointing this out, because as a German user, I have been having a similar problem: In Germany, we use a QWERTZ layout (with "Y" and "Z" being switched), and for a lot of Flash games in RuffleWeb, typing the "Z" key returns a "Y" instead (and the other way around).
Would be super-cool if this could be fixed some day! As always: Thanks to all Ruffle contributors, I am so grateful for your work :)
Ruffle uses KeyboardEvent.code to determine which physical key was pressed. Unfortunately that ignores keyboard layout. KeyboardEvent.key doesn't but that is the actual character, as is a or A if shift is pressed or any other letter in any alphabet.
The documentation has Keyboard.getLayoutMap which is supposed to solve this problem but this isn't supported in all browsers: https://developer.mozilla.org/en-US/docs/Web/API/Keyboard/getLayoutMap. It's actually experimental and it is not sure at all whether it will be supported in the future (security concerns: https://mozilla.github.io/standards-positions/#keyboard-map).
For reference, this is related to #1046.
any update on this?