Unpress all keys on blur to avoid stuck keys
This commit is contained in:
parent
5220e32e77
commit
467fa3d7da
1 changed files with 5 additions and 0 deletions
|
@ -392,6 +392,11 @@ EM_BOOL
|
||||||
Emscripten_HandleFocus(int eventType, const EmscriptenFocusEvent *wheelEvent, void *userData)
|
Emscripten_HandleFocus(int eventType, const EmscriptenFocusEvent *wheelEvent, void *userData)
|
||||||
{
|
{
|
||||||
SDL_WindowData *window_data = userData;
|
SDL_WindowData *window_data = userData;
|
||||||
|
/* If the user switches away while keys are pressed (such as
|
||||||
|
* via Alt+Tab), key release events won't be received. */
|
||||||
|
if (eventType == EMSCRIPTEN_EVENT_BLUR) {
|
||||||
|
SDL_ResetKeyboard();
|
||||||
|
}
|
||||||
SDL_SendWindowEvent(window_data->window, eventType == EMSCRIPTEN_EVENT_FOCUS ? SDL_WINDOWEVENT_FOCUS_GAINED : SDL_WINDOWEVENT_FOCUS_LOST, 0, 0);
|
SDL_SendWindowEvent(window_data->window, eventType == EMSCRIPTEN_EVENT_FOCUS ? SDL_WINDOWEVENT_FOCUS_GAINED : SDL_WINDOWEVENT_FOCUS_LOST, 0, 0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue