Skip to content

Commit

Permalink
GTK: Use key without modifiers applied for KeyEventArgs.Key
Browse files Browse the repository at this point in the history
  • Loading branch information
psyGamer committed Jun 29, 2024
1 parent 3a3b029 commit 50fad8c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Eto.Gtk/GtkConversions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 50fad8c

Please sign in to comment.