Hi Vernon Marsden,
Using .NET 4, you can use ModifierKeys.HasFlag method.
I made a test in Form_keyDown event you can refer to.
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs)
If ModifierKeys.HasFlag(Keys.Control) Then
' MessageBox.Show("Ctrl is pressed!")
End If
End Sub
If you're not using .NET 4, the availability of Enum.HasFlag is not applicable.
You can use following code to achieve the same result:
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs)
If (Control.ModifierKeys And Keys.Control) = Keys.Control Then
' MessageBox.Show("Ctrl is pressed!")
End If
End Sub
Best Regards,
Daniel Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.