Skip to content

Commit

Permalink
Merge pull request #2668 from psyGamer/develop
Browse files Browse the repository at this point in the history
Use base key for key event in GTK
  • Loading branch information
cwensley committed Jul 1, 2024
2 parents 3a3b029 + 50fad8c commit c24702f
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 c24702f

Please sign in to comment.