C# detect pressing Windows key

609 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 answers

0
pbondoer On

I suggest you try with Keys.LWin.

0
JBB On

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