# SDL: Fixed internal Windows key state when using Windows+Space or Windows+G shortcuts

**URL:** <https://discourse.libsdl.org/t/sdl-fixed-internal-windows-key-state-when-using-windows-space-or-windows-g-shortcuts/32223>\
**Category:** SDL Commits\
**Created:** [July 24, 2021, 10:50pm UTC](https://discourse.libsdl.org/t/sdl-fixed-internal-windows-key-state-when-using-windows-space-or-windows-g-shortcuts/32223 "2021-07-24T22:50:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SDLPushPostBot](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/sdlpushpostbot/32/4370_2.png) [@SDLPushPostBot](https://discourse.libsdl.org/u/SDLPushPostBot)\
**Post date:** [July 24, 2021, 10:50pm UTC](https://discourse.libsdl.org/t/sdl-fixed-internal-windows-key-state-when-using-windows-space-or-windows-g-shortcuts/32223/1 "2021-07-24T22:50:02Z")

</div>

> <https://github.com/libsdl-org/SDL/commit/3b85e3fdfce01c528a6ebf9ac537bdc106ba4963>
>
> This fixes bugs:
> https://github.com/libsdl-org/SDL/issues/4369
> https://github.c…om/libsdl-org/SDL/issues/4500

```diff
From 3b85e3fdfce01c528a6ebf9ac537bdc106ba4963 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sat, 24 Jul 2021 15:47:11 -0700
Subject: [PATCH] Fixed internal Windows key state when using Windows+Space or
 Windows+G shortcuts

This fixes bugs:
https://github.com/libsdl-org/SDL/issues/4369
https://github.com/libsdl-org/SDL/issues/4500
---
 src/video/windows/SDL_windowsevents.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c
index 06857d7249..01fd369b36 100644
--- a/src/video/windows/SDL_windowsevents.c
+++ b/src/video/windows/SDL_windowsevents.c
@@ -1365,6 +1365,13 @@ WIN_PumpEvents(_THIS)
     if ((keystate[SDL_SCANCODE_RSHIFT] == SDL_PRESSED) && !(GetKeyState(VK_RSHIFT) & 0x8000)) {
         SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RSHIFT);
     }
+ /* The Windows key state gets lost when using Windows+Space or Windows+G shortcuts */
+ if ((keystate[SDL_SCANCODE_LGUI] == SDL_PRESSED) && !(GetKeyState(VK_LWIN) & 0x8000)) {
+ SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LGUI);
+ }
+ if ((keystate[SDL_SCANCODE_RGUI] == SDL_PRESSED) && !(GetKeyState(VK_RWIN) & 0x8000)) {
+ SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RGUI);
+ }
 
     /* Update the clipping rect in case someone else has stolen it */
     WIN_UpdateClipCursorForWindows();

```
