Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to detect if the windows key is pressed?

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 !

like image 810
Patrice Avatar asked Dec 09 '25 15:12

Patrice


1 Answers

Check this out:

Keys Enumeration

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
like image 56
Leniel Maccaferri Avatar answered Dec 11 '25 13:12

Leniel Maccaferri



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!