KeyboardHelper.cs
1 // Copyright (c) Microsoft Corporation 2 // The Microsoft Corporation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using System.Windows.Input; 6 7 using Wox.Plugin; 8 9 namespace PowerLauncher.Helper 10 { 11 internal sealed class KeyboardHelper 12 { 13 public static SpecialKeyState CheckModifiers() 14 { 15 SpecialKeyState state = new SpecialKeyState(); 16 if ((Keyboard.GetKeyStates(Key.LeftShift) & KeyStates.Down) > 0 || 17 (Keyboard.GetKeyStates(Key.RightShift) & KeyStates.Down) > 0) 18 { 19 state.ShiftPressed = true; 20 } 21 22 if ((Keyboard.GetKeyStates(Key.LWin) & KeyStates.Down) > 0 || 23 (Keyboard.GetKeyStates(Key.RWin) & KeyStates.Down) > 0) 24 { 25 state.WinPressed = true; 26 } 27 28 if ((Keyboard.GetKeyStates(Key.LeftCtrl) & KeyStates.Down) > 0 || 29 (Keyboard.GetKeyStates(Key.RightCtrl) & KeyStates.Down) > 0) 30 { 31 state.CtrlPressed = true; 32 } 33 34 if ((Keyboard.GetKeyStates(Key.LeftAlt) & KeyStates.Down) > 0 || 35 (Keyboard.GetKeyStates(Key.RightAlt) & KeyStates.Down) > 0) 36 { 37 state.AltPressed = true; 38 } 39 40 return state; 41 } 42 } 43 }