C# detect pressing Windows key

628 Views Asked by At

I create a text box for entering a combination of global hot keys, which can then be used in the program. For this purpose I use event TextBox.KeyDown and look the KeyEventArgs. But the problem is that I have not found how to use the KeyEventArgs to see whether the Windows-key is pressed. Properties KeyCode, Modifiers use enum type Keys, which has no value for the Windows-key, because when you press the Windows-key, then KeyDown event is triggered, but the Modifiers property contains None.

What to do?

2

There are 2 best solutions below

0
On

I suggest you try with Keys.LWin.

0
On

Try Keys.LWin and Keys.RWin for the keycode enum