We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3259 - Emscripten's key events should attempt to use the 'code' property.
Summary: Emscripten's key events should attempt to use the 'code' property.
Status: ASSIGNED
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: HG 2.1
Hardware: Other All
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords: target-2.0.16
Depends on:
Blocks:
 
Reported: 2016-02-15 18:42 UTC by Tanner Rogalsky
Modified: 2020-07-16 17:35 UTC (History)
2 users (show)

See Also:


Attachments
Updated patch (24.29 KB, patch)
2020-07-16 17:16 UTC, Charlie Birks
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tanner Rogalsky 2016-02-15 18:42:09 UTC
On the emscripten platform, `Emscripten_HandleKey` in `SDL_emscriptenevents.c` maps key codes directly to scancodes which results in scancodes never differing from keycodes.

HandleKey should attempt to use the `code` property on the `EmscriptenKeyboardEvent` object first, if it exists, to get the correct scan code.
Comment 1 Emil Lenngren 2020-01-01 14:26:47 UTC
Yes, please implement this. I have a game which uses SDL scancodes to work properly regardless of keyboard layout, but noticed that it doesn't work correctly when compiling for the emscripten target when I have a Dvorak keyboard.
Comment 2 Charlie Birks 2020-07-14 10:45:16 UTC
There's currently an unmerged downstream patch for this: https://github.com/emscripten-ports/SDL2/pull/117
Comment 3 Sam Lantinga 2020-07-15 22:48:51 UTC
The patch doesn't cleanly apply, but conceptually seems good.

Ryan, can you review for 2.0.14?
Comment 4 Ryan C. Gordon 2020-07-16 17:02:54 UTC
Let's get this into 2.0.16, but I don't want to apply it to the almost-done 2.0.14.

--ryan.
Comment 5 Charlie Birks 2020-07-16 17:16:48 UTC
Created attachment 4418 [details]
Updated patch

Fixed the patch, not too sure about the KaiOS bits.
Comment 6 Charlie Birks 2020-07-16 17:35:06 UTC
This does break support for (old) browsers that don't support `.code`. I don't know if that's actually a problem for anyone...