From 50fad8c02fe2d00ee651d4d5cc1c0d2f9eed3097 Mon Sep 17 00:00:00 2001 From: psyGamer Date: Sat, 29 Jun 2024 12:47:06 +0200 Subject: [PATCH] GTK: Use key without modifiers applied for KeyEventArgs.Key --- src/Eto.Gtk/GtkConversions.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Eto.Gtk/GtkConversions.cs b/src/Eto.Gtk/GtkConversions.cs index 23ecafb6cb..885a2944fa 100644 --- a/src/Eto.Gtk/GtkConversions.cs +++ b/src/Eto.Gtk/GtkConversions.cs @@ -516,7 +516,15 @@ public static Cairo.FillRule ToCairo(this FillMode value) public static KeyEventArgs ToEto(this Gdk.EventKey args) { - Keys key = args.Key.ToEto() | args.State.ToEtoKey(); + Keys key; + + // Try to use the base key without modifiers already being applied. + // For example: Shift+Semicolon would then actually report that in the key event, instead of Shift+None (technically 'colon', but that isn't mapped) + Gdk.Keymap.Default.GetEntriesForKeycode(args.HardwareKeycode, out _, out uint[] keyvals); + if (keyvals.Length != 0) + key = ((Gdk.Key)keyvals[0]).ToEto() | args.State.ToEtoKey(); + else + key = args.Key.ToEto() | args.State.ToEtoKey(); KeyEventType keyEventType = args.Type == Gdk.EventType.KeyRelease ? KeyEventType.KeyUp : KeyEventType.KeyDown;