summaryrefslogtreecommitdiffstats
path: root/src/gui_w32.c
diff options
context:
space:
mode:
authorAnton Sharonov <anton.sharonov@gmail.com>2022-10-07 16:28:48 +0100
committerBram Moolenaar <Bram@vim.org>2022-10-07 16:28:48 +0100
commit8d8b9758ced52b6303af95ad7e28ae9c5636cdf8 (patch)
tree27e6e4682c8ad8c196c07cb412ba629484dffeed /src/gui_w32.c
parent07eaa1ede4a39b6a95203beebd94943b62a216c1 (diff)
patch 9.0.0686: the right ALT key does not work on some MS-Windows keyboardsv9.0.0686
Problem: The right ALT key does not work on some MS-Windows keyboards. Solution: Adjust the modifiers based on GetKeyState(). (Anoton Sharonov, closes #11300)
Diffstat (limited to 'src/gui_w32.c')
-rw-r--r--src/gui_w32.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/gui_w32.c b/src/gui_w32.c
index 5e8fbe2a80..2dc54bf5f8 100644
--- a/src/gui_w32.c
+++ b/src/gui_w32.c
@@ -852,6 +852,13 @@ get_active_modifiers(void)
modifiers |= MOD_MASK_ALT;
if ((modifiers & MOD_MASK_CTRL) && (GetKeyState(VK_RMENU) & 0x8000))
modifiers &= ~MOD_MASK_CTRL;
+ // Add RightALT only if it is hold alone (without Ctrl), because if AltGr
+ // is pressed, Windows claims that Ctrl is hold as well. That way we can
+ // recognize Right-ALT alone and be sure that not AltGr is hold.
+ if (!(GetKeyState(VK_CONTROL) & 0x8000)
+ && (GetKeyState(VK_RMENU) & 0x8000)
+ && !(GetKeyState(VK_LMENU) & 0x8000)) // seems AltGr has both set
+ modifiers |= MOD_MASK_ALT;
return modifiers;
}