Skip to content

Commit 54fcaa0

Browse files
committed
refactor: Improve key modifier checks and AltGr detection
1 parent b75676a commit 54fcaa0

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/Views/Launcher.axaml.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,19 @@ protected override void OnKeyDown(KeyEventArgs e)
112112
// We should clear all unhandled key modifiers.
113113
_unhandledModifiers = KeyModifiers.None;
114114

115+
// Check for AltGr (which is detected as Ctrl+Alt)
116+
bool isAltGr = e.KeyModifiers.HasFlag(KeyModifiers.Control) &&
117+
e.KeyModifiers.HasFlag(KeyModifiers.Alt);
118+
119+
// Skip hotkey processing if AltGr is pressed
120+
if (isAltGr)
121+
{
122+
base.OnKeyDown(e);
123+
return;
124+
}
125+
115126
// Ctrl+Shift+P opens preference dialog (macOS use hotkeys in system menu bar)
116-
if (!OperatingSystem.IsMacOS() && e.KeyModifiers == (KeyModifiers.Control | KeyModifiers.Shift) && e.Key == Key.P)
127+
if (!OperatingSystem.IsMacOS() && e is { KeyModifiers: (KeyModifiers.Control | KeyModifiers.Shift), Key: Key.P })
117128
{
118129
App.OpenDialog(new Preferences());
119130
e.Handled = true;
@@ -246,10 +257,12 @@ protected override void OnKeyDown(KeyEventArgs e)
246257
if (!_unhandledModifiers.HasFlag(KeyModifiers.Alt) && (e.Key == Key.LeftAlt || e.Key == Key.RightAlt))
247258
_unhandledModifiers |= KeyModifiers.Alt;
248259

249-
if (!_unhandledModifiers.HasFlag(KeyModifiers.Control) && (e.Key == Key.LeftCtrl || e.Key == Key.RightCtrl))
260+
if (!_unhandledModifiers.HasFlag(KeyModifiers.Control) &&
261+
e.Key is Key.LeftCtrl or Key.RightCtrl)
250262
_unhandledModifiers |= KeyModifiers.Control;
251263

252-
if (!_unhandledModifiers.HasFlag(KeyModifiers.Shift) && (e.Key == Key.LeftShift || e.Key == Key.RightShift))
264+
if (!_unhandledModifiers.HasFlag(KeyModifiers.Shift) &&
265+
e.Key is Key.LeftShift or Key.RightShift)
253266
_unhandledModifiers |= KeyModifiers.Shift;
254267
}
255268
}

0 commit comments

Comments
 (0)