Skip to content

Commit

Permalink
emscripten: restore key event prevent default behaviour
Browse files Browse the repository at this point in the history
This restores the behaviour before 9221548 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)
  • Loading branch information
Daft-Freak authored and slouken committed Jul 19, 2024
1 parent fd32342 commit 6e931be
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/video/emscripten/SDL_emscriptenevents.c
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ static EM_BOOL Emscripten_HandleKey(int eventType, const EmscriptenKeyboardEvent
{
const SDL_Keycode keycode = Emscripten_MapKeyCode(keyEvent);
SDL_Scancode scancode = Emscripten_MapScanCode(keyEvent->code);
SDL_bool prevent_default = SDL_GetEventState(eventType == EMSCRIPTEN_EVENT_KEYDOWN ? SDL_KEYDOWN : SDL_KEYUP) == SDL_ENABLE;
SDL_bool prevent_default = SDL_FALSE;
SDL_bool is_nav_key = SDL_FALSE;

if (scancode == SDL_SCANCODE_UNKNOWN) {
Expand All @@ -807,7 +807,7 @@ static EM_BOOL Emscripten_HandleKey(int eventType, const EmscriptenKeyboardEvent
}

if (scancode != SDL_SCANCODE_UNKNOWN) {
SDL_SendKeyboardKeyAndKeycode(eventType == EMSCRIPTEN_EVENT_KEYDOWN ? SDL_PRESSED : SDL_RELEASED, scancode, keycode);
prevent_default = SDL_SendKeyboardKeyAndKeycode(eventType == EMSCRIPTEN_EVENT_KEYDOWN ? SDL_PRESSED : SDL_RELEASED, scancode, keycode);
}

/* if TEXTINPUT events are enabled we can't prevent keydown or we won't get keypress
Expand Down

0 comments on commit 6e931be

Please sign in to comment.