-
Notifications
You must be signed in to change notification settings - Fork 64
Keyboard input does not handle DOM keyboard events with modern attributes #108
Comments
Yes, we are using the legacy It might be possible to fix this without a rewrite depending on the Relevant code: |
@Daft-Freak Thank you for your feedback. Do you have an idea, why Emscripten's SDL works perfectly fine on Safari and Chrome but not on Firefox? About your feedback: I went to https://keycode.info/ and found out that for example the keycode for the non working "+" key on the German keyboard is So this
would need to be changed to Unfortunatelly, there is no https://wiki.libsdl.org/SDL_Scancode Might sending unknown Scancodes via |
@Daft-Freak : Additionally to what I wrote above: I had another idea: Firefox does not work. But Chrome does. So I used Chrome, went to http://sy2002.de/keytest/keytest.html and pressed "+": It outputs "Scancode: 46" and "Keycode: 61". According to https://wiki.libsdl.org/SDLScancodeLookup scancode 46 is SDL_SCANCODE_EQUALS Would this mean, that would need to read
If this is the right approach, here are the values - there are just 5 keys that are not working:
EDIT: No that does not seem to be the right approach, because e.g. pressing comma "," leads to the same keycode in Chrome than pressing "<". I guess I will need to experiment a bit using Emscripten and a locally compiled version of SDL2. |
Hmm, I would check what scancodes native SDL generates. If some browsers are generating the same |
@Daft-Freak You are right, using native SDL helped: I did compile the above-mentioned test program natively. Here are the results:
Additionally, as a sanity check: I checked the positions of e.g. SDL_SCANCODE_MINUS on a U.S. keyboard and compared them to e.g. the position of the "ß" key on a German keyboard: Fits nicely. so the above-mentioned mapping seems to be sensible. If you'd like to add it like this, would be great. I can do a PR, if you prefer. |
I've pushed a commit with those mappings (since it shouldn't break anything). |
Thank you for your fast help! :-) I will gladly test it so that we can close this issue, soon. |
@Daft-Freak Thank you that you committed this one so quickly. I just wanted to test it and need to admit that I never compiled SDL2 for emscripten before. I conveniently always used
Worked. I got
Worked. I got
Obviously I did something wrong :-) Any ideas? |
Hmm, it's been a while since I've compiled manually. Possibly a conflict with SDL1? You should be able to use |
@Daft-Freak Thank you this was very helpful: It worked, I was able to test and we can close the issue now:
I think on the long run, we might need to switch to the modern attributes, but I guess for now everything is OK. |
This issue is about a discussion I had with the maintainers of Firefox:
https://bugzilla.mozilla.org/show_bug.cgi?id=1622670
There is a bug/problem in Firefox, which leads to the effect, that this very simple SDL program is not able to receive keypresses like "+" and "#" on german keyboards at the Emscripten/WebAssembly/WebGL target. Here is the code:
https://pastebin.com/k6b153mf
Here is this code, compiled with Emscripten and SDL for Emscripten to play with online:
http://sy2002.de/keytest/keytest.html
Open the website, type on your keyboard and see, how you see the scancode and the keycode in the console. Now, if you use Chrome and Safari: No problems at all. But if you use Firefox and a German keyboard, then you are not able to enter a "+" or a "#" or a "^" or a "ß" because as you can see in the demo above: There are zero events forwarded to SDL by Firefox.
The Firefox team claims (citation from the bugzilla link above): "I guess it [SDL] does not handle DOM keyboard events with modern attributes."
After that, the Firefox team lowered the priority to P3, which means it might take quite long to be fixed.
I do not know what the Chrome team or the Safari team do different - because everthing works fine there - and I do not know if they do it right or Firefox does it right.
Unfortunatelly, I am not savvy enough in DOM to have an own opinion. This is why I wanted to share this with the Emscripten/SDL2 community: Just in case the Firefox team is right and the SDL port is really (whatever this means) "not handling DOM keyboard events with modern attributes", then this might be a bug in the SDL port.
The text was updated successfully, but these errors were encountered: