When I inspect the keycode associated with a keydown event using event.key.keysym.sym, the value returned is a SDL_Scancode instead of a SDL_Keycode. I would expect event.key.keysym.sym to return a SDL_Keycode according to the SDL documentation. Example:
SDL_Event e;
while (SDL_PollEvent(&e) != 0) {
if (e.type == SDL_KEYDOWN) {
if (e.key.keysym.sym == SDLK_a) {
printf("When I press the A key on my keyboard, this branch does NOT execute\n");
} else if (e.key.keysym.sym == SDL_SCANCODE_A) {
printf("This branch DOES execute when I press the A key on my keyboard.\n");
}
}
}
I'm using Emscripten 3.1.54, which uses SDL 2.26.0. I'm compiling the code with the following command:
emcc main.c -o index.html -sUSE_SDL=2
I'm opening the generated page in Chrome Version 121.0.6167.160 on MacOS 11.7.10.