From 24641b6cad9cfc465f4bea220bc48bb92091acf2 Mon Sep 17 00:00:00 2001 From: Federico Terzi Date: Tue, 2 Jun 2020 21:37:53 +0200 Subject: [PATCH] Fix bug #306 that prevented ALT key from working correctly on Windows. --- native/libwinbridge/bridge.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/native/libwinbridge/bridge.cpp b/native/libwinbridge/bridge.cpp index fcc4d9e..febcb60 100644 --- a/native/libwinbridge/bridge.cpp +++ b/native/libwinbridge/bridge.cpp @@ -210,16 +210,18 @@ LRESULT CALLBACK window_procedure(HWND window, unsigned int msg, WPARAM wp, LPAR // Convert the input data RAWINPUT* raw = reinterpret_cast(lpb.data()); - // Make sure it's a keyboard type event, relative to a key press. if (raw->header.dwType == RIM_TYPEKEYBOARD) { // We only want KEY UP AND KEY DOWN events - if (raw->data.keyboard.Message != WM_KEYDOWN && raw->data.keyboard.Message != WM_KEYUP) { + if (raw->data.keyboard.Message != WM_KEYDOWN && raw->data.keyboard.Message != WM_KEYUP && + raw->data.keyboard.Message != WM_SYSKEYDOWN) { return 0; } - int is_key_down = raw->data.keyboard.Message == WM_KEYDOWN; + // The alt key sends a SYSKEYDOWN instead of KEYDOWN event + int is_key_down = raw->data.keyboard.Message == WM_KEYDOWN || + raw->data.keyboard.Message == WM_SYSKEYDOWN; DWORD currentTick = GetTickCount();