mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-05 19:08:12 +00:00
emscripten: restore key event prevent default behaviour
This restores the behaviour before9221548114
where we only preventDefault the event if: - the key is recognised - the event is enabled - the event is not filtered (ignoring the KEYPRESS special case, which is unchanged) (cherry picked from commit6e931bee01
)
This commit is contained in:

committed by
Sam Lantinga

parent
f8c1cd6622
commit
25559faaea
@@ -458,7 +458,7 @@ static EM_BOOL Emscripten_HandleKey(int eventType, const EmscriptenKeyboardEvent
|
||||
SDL_WindowData *window_data = (SDL_WindowData *)userData;
|
||||
SDL_Scancode scancode = Emscripten_MapScanCode(keyEvent->code);
|
||||
SDL_Keycode keycode = SDLK_UNKNOWN;
|
||||
SDL_bool prevent_default = SDL_TRUE;
|
||||
SDL_bool prevent_default = SDL_FALSE;
|
||||
SDL_bool is_nav_key = SDL_FALSE;
|
||||
|
||||
if (scancode == SDL_SCANCODE_UNKNOWN) {
|
||||
@@ -511,9 +511,9 @@ static EM_BOOL Emscripten_HandleKey(int eventType, const EmscriptenKeyboardEvent
|
||||
}
|
||||
|
||||
if (keycode != SDLK_UNKNOWN) {
|
||||
SDL_SendKeyboardKeyAndKeycode(0, SDL_DEFAULT_KEYBOARD_ID, 0, scancode, keycode, eventType == EMSCRIPTEN_EVENT_KEYDOWN ? SDL_PRESSED : SDL_RELEASED);
|
||||
prevent_default = SDL_SendKeyboardKeyAndKeycode(0, SDL_DEFAULT_KEYBOARD_ID, 0, scancode, keycode, eventType == EMSCRIPTEN_EVENT_KEYDOWN ? SDL_PRESSED : SDL_RELEASED);
|
||||
} else {
|
||||
SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, 0, scancode, eventType == EMSCRIPTEN_EVENT_KEYDOWN ? SDL_PRESSED : SDL_RELEASED);
|
||||
prevent_default = SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, 0, scancode, eventType == EMSCRIPTEN_EVENT_KEYDOWN ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
/* if TEXTINPUT events are enabled we can't prevent keydown or we won't get keypress
|
||||
|
Reference in New Issue
Block a user