From ae17e0c264c562fc6765ee1ad1e0ee0997edb4fb Mon Sep 17 00:00:00 2001 From: chao wan <1013448513@qq.com> Date: Tue, 28 Feb 2023 23:32:58 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=85=A8=E5=B1=80=E7=83=AD?= =?UTF-8?q?=E9=94=AE=E4=B8=8D=E8=83=BD=E5=BD=95=E5=88=B6Alt=E7=BB=84?= =?UTF-8?q?=E5=90=88=E9=94=AE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Views/GlobalHotkeySettingWindow.xaml.cs | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/v2rayN/v2rayN/Views/GlobalHotkeySettingWindow.xaml.cs b/v2rayN/v2rayN/Views/GlobalHotkeySettingWindow.xaml.cs index ef92e71f..16cc7fce 100644 --- a/v2rayN/v2rayN/Views/GlobalHotkeySettingWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/GlobalHotkeySettingWindow.xaml.cs @@ -57,19 +57,21 @@ namespace v2rayN.Views private void TxtGlobalHotkey_KeyDown(object sender, KeyEventArgs e) { - var txt = ((TextBox)sender); - var index = Utils.ToInt(txt.Name.Substring(txt.Name.Length - 1, 1)); - - if (e.Key == Key.System) - return; - var formsKey = (Forms.Keys)KeyInterop.VirtualKeyFromKey(e.Key); + e.Handled = true; + var _ModifierKeys = new Key[] { Key.LeftCtrl, Key.RightCtrl, Key.LeftShift, Key.RightShift, Key.LeftAlt, Key.RightAlt }; + if (!_ModifierKeys.Contains(e.Key) && !_ModifierKeys.Contains(e.SystemKey)) + { + var txt = ((TextBox)sender); + var index = Utils.ToInt(txt.Name.Substring(txt.Name.Length - 1, 1)); + var formsKey = (Forms.Keys)KeyInterop.VirtualKeyFromKey(e.Key == Key.System ? e.SystemKey : e.Key); - lstKey[index].KeyCode = formsKey; - lstKey[index].Alt = Keyboard.IsKeyDown(Key.LeftAlt) || Keyboard.IsKeyDown(Key.RightAlt); - lstKey[index].Control = Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl); - lstKey[index].Shift = Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift); + lstKey[index].KeyCode = formsKey; + lstKey[index].Alt = (Keyboard.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt; + lstKey[index].Control = (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control; + lstKey[index].Shift = (Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift; - BindingData(index); + BindingData(index); + } } private void BindingData(int index)