From 96e29905643b0c34369a6321436ee347cc4f2bfd Mon Sep 17 00:00:00 2001 From: stk Date: Wed, 3 Jan 2024 17:28:05 +0100 Subject: [PATCH] Don't set modifiers for AltGr on Windows AltGr is the same as ctrl+alt, and we don't want those to be set when you press a key using AltGr. --- console_win.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/console_win.go b/console_win.go index a403668..ffa0049 100644 --- a/console_win.go +++ b/console_win.go @@ -599,12 +599,17 @@ func geti16(v []byte) int16 { func mod2mask(cks uint32) ModMask { mm := ModNone // Left or right control - if (cks & (0x0008 | 0x0004)) != 0 { - mm |= ModCtrl - } + ctrl := (cks & (0x0008 | 0x0004)) != 0 // Left or right alt - if (cks & (0x0002 | 0x0001)) != 0 { - mm |= ModAlt + alt := (cks & (0x0002 | 0x0001)) != 0 + // Filter out ctrl+alt (it means AltGr) + if !(ctrl && alt) { + if ctrl { + mm |= ModCtrl + } + if alt { + mm |= ModAlt + } } // Any shift if (cks & 0x0010) != 0 {