[emscripten] Use keyEvent->key instead of deprecated charCode

keyEvent->charCode is deprecated in DOM Level 3 and marked deprecated
in Emscripten's html5.h. Use keyEvent->key instead.
This commit is contained in:
Sam Clegg
2026-08-21 22:21:14 -07:00
committed by Sam Lantinga
parent a0db66a718
commit f0b84476f9

View File

@@ -467,11 +467,10 @@ static EM_BOOL Emscripten_HandleKeyPress(int eventType, const EmscriptenKeyboard
SDL_WindowData *window_data = (SDL_WindowData *)userData;
if (SDL_TextInputActive(window_data->window)) {
char text[5];
char *end = SDL_UCS4ToUTF8(keyEvent->charCode, text);
*end = '\0';
SDL_SendKeyboardText(text);
return EM_TRUE;
if (SDL_utf8strlen(keyEvent->key) == 1) {
SDL_SendKeyboardText(keyEvent->key);
return EM_TRUE;
}
}
return EM_FALSE;
}