I would like to be able to detect when the windows Key is pressed. I tried with getasynckeystate function bug didnt found the right virtual key. thanks for your help !
how to detect if the windows key is pressed?
3.9k views Asked by Patrice At
3
There are 3 answers
0

Check this out:
You're looking for these key codes:
LWin The left Windows logo key (Microsoft Natural Keyboard).
RWin The right Windows logo key (Microsoft Natural Keyboard).
Sample code:
Public Sub TextBox1_KeyPress(ByVal sender As Object, _
ByVal e As KeyPressEventArgs) Handles TextBox1.KeyPress
If (e.Key = Key.LWin Or e.Key = Key.RWin) Then
MsgBox("Pressed Windows Key")
End If
End Sub
The key codes are given on the Keys Enumeration page:
It doesn't indicate whether either (if any) of these codes is obtained when using a keyboard other than the Microsoft Natural Keyboard.
If you are using WinForms then you need to trap the KeyDown Event
If you are using WPF then you need the Keyboard.KeyDown Event