I need to check if the SHIFT or CTRL keys are being pressed in my VB.net application, any ideas? (get a boolean)
The following will return True or False depending on whether the key is pressed at that moment. From the wording of your question, I assume you are not asking about event handling, which is what the other answers have addressed.
My.Computer.Keyboard.ShiftKeyDown
My.Computer.Keyboard.CtrlKeyDown
If Control.ModifierKeys = Keys.Shift Or Control.ModifierKeys = Keys.Control Then
' Shift, Ctrl, or Shift+Ctrl is being pressed
Else
' Neither Shift nor Ctrl is being pressed
End If
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With