Unpress all keys on blur to avoid stuck keys
authorBoris Gjenero <boris.gjenero@gmail.com>
Tue, 13 Sep 2016 00:03:49 -0700
changeset 103283e6cd603c977
parent 10327 47d840cce014
child 10329 ad0bee16b6b9
Unpress all keys on blur to avoid stuck keys
src/video/emscripten/SDL_emscriptenevents.c
     1.1 --- a/src/video/emscripten/SDL_emscriptenevents.c	Tue Sep 13 00:03:48 2016 -0700
     1.2 +++ b/src/video/emscripten/SDL_emscriptenevents.c	Tue Sep 13 00:03:49 2016 -0700
     1.3 @@ -392,6 +392,11 @@
     1.4  Emscripten_HandleFocus(int eventType, const EmscriptenFocusEvent *wheelEvent, void *userData)
     1.5  {
     1.6      SDL_WindowData *window_data = userData;
     1.7 +    /* If the user switches away while keys are pressed (such as
     1.8 +     * via Alt+Tab), key release events won't be received. */
     1.9 +    if (eventType == EMSCRIPTEN_EVENT_BLUR) {
    1.10 +        SDL_ResetKeyboard();
    1.11 +    }
    1.12      SDL_SendWindowEvent(window_data->window, eventType == EMSCRIPTEN_EVENT_FOCUS ? SDL_WINDOWEVENT_FOCUS_GAINED : SDL_WINDOWEVENT_FOCUS_LOST, 0, 0);
    1.13      return 1;
    1.14  }