From 0c58c2b4f93569a56bd5a6cfa493af749958a3dd Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Tue, 10 Jan 2023 15:01:30 +0800 Subject: [PATCH] Ban single character key --- Flow.Launcher.Infrastructure/Hotkey/HotkeyModel.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher.Infrastructure/Hotkey/HotkeyModel.cs b/Flow.Launcher.Infrastructure/Hotkey/HotkeyModel.cs index e4a020cb7..54115f129 100644 --- a/Flow.Launcher.Infrastructure/Hotkey/HotkeyModel.cs +++ b/Flow.Launcher.Infrastructure/Hotkey/HotkeyModel.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Windows.Input; +using System.Windows.Navigation; namespace Flow.Launcher.Infrastructure.Hotkey { @@ -148,7 +149,7 @@ namespace Flow.Launcher.Infrastructure.Hotkey return string.Join(" + ", keys); } - private static bool ValidateHotkey(Key key) + private bool ValidateHotkey(Key key) { HashSet invalidKeys = new() { @@ -158,7 +159,15 @@ namespace Flow.Launcher.Infrastructure.Hotkey Key.LWin, Key.RWin, }; - return !invalidKeys.Contains(key); + if (invalidKeys.Contains(key)) + { + return false; + } + if (ModifierKeys == ModifierKeys.None) + { + return key >= Key.F1 && key <= Key.F24; + } + return true; } public override bool Equals(object obj)