src/video/emscripten/SDL_emscriptenevents.c
changeset 11025 2215b66794ba
parent 11024 32026cc5015a
child 11034 fcb1f3161d2e
     1.1 --- a/src/video/emscripten/SDL_emscriptenevents.c	Wed May 24 14:04:25 2017 +0100
     1.2 +++ b/src/video/emscripten/SDL_emscriptenevents.c	Wed May 24 14:04:39 2017 +0100
     1.3 @@ -522,7 +522,14 @@
     1.4      /* if TEXTINPUT events are enabled we can't prevent keydown or we won't get keypress
     1.5       * we need to ALWAYS prevent backspace and tab otherwise chrome takes action and does bad navigation UX
     1.6       */
     1.7 -    if (eventType == EMSCRIPTEN_EVENT_KEYDOWN && SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE && keyEvent->keyCode != 8 /* backspace */ && keyEvent->keyCode != 9 /* tab */)
     1.8 +    SDL_bool is_nav_key = keyEvent->keyCode == 8 /* backspace */ ||
     1.9 +                          keyEvent->keyCode == 9 /* tab */ ||
    1.10 +                          keyEvent->keyCode == 37 /* left */ ||
    1.11 +                          keyEvent->keyCode == 38 /* up */ ||
    1.12 +                          keyEvent->keyCode == 39 /* right */ ||
    1.13 +                          keyEvent->keyCode == 40 /* down */;
    1.14 +
    1.15 +    if (eventType == EMSCRIPTEN_EVENT_KEYDOWN && SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE && !is_nav_key)
    1.16          prevent_default = SDL_FALSE;
    1.17  
    1.18      return prevent_default;