emscripten: Don't prevent default on filtered key events

This commit is contained in:
Charlie Birks 2020-12-01 12:46:59 +00:00 committed by Charlie Birks
parent afb0606f5a
commit 9de97e19cc
1 changed files with 2 additions and 4 deletions

View File

@ -493,7 +493,7 @@ static EM_BOOL
Emscripten_HandleKey(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData)
{
Uint32 scancode;
SDL_bool prevent_default;
SDL_bool prevent_default = SDL_FALSE;
SDL_bool is_nav_key;
/* .keyCode is deprecated, but still the most reliable way to get keys */
@ -577,12 +577,10 @@ Emscripten_HandleKey(int eventType, const EmscriptenKeyboardEvent *keyEvent, voi
break;
}
}
SDL_SendKeyboardKey(eventType == EMSCRIPTEN_EVENT_KEYDOWN ? SDL_PRESSED : SDL_RELEASED, scancode);
prevent_default = SDL_SendKeyboardKey(eventType == EMSCRIPTEN_EVENT_KEYDOWN ? SDL_PRESSED : SDL_RELEASED, scancode);
}
}
prevent_default = SDL_GetEventState(eventType == EMSCRIPTEN_EVENT_KEYDOWN ? SDL_KEYDOWN : SDL_KEYUP) == SDL_ENABLE;
/* if TEXTINPUT events are enabled we can't prevent keydown or we won't get keypress
* we need to ALWAYS prevent backspace and tab otherwise chrome takes action and does bad navigation UX
*/