I am trying to trap combinations of the ALT/SHIFT keys in the KeyDown event of a form, using this code:
Private Sub frmMDI_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If Control.ModifierKeys = Keys.Shift Or Control.ModifierKeys = Keys.Alt Then
'do something
End If
End Sub
This successfully traps if EITHER key is pressed. However, if in order to trap events when BOTH keys are pressed I replace the "Or" with "And", as here:
If Control.ModifierKeys = Keys.Shift And Control.ModifierKeys = Keys.Alt Then
'do something
End If
then NOTHING happens at all. What am I missing here?
Private Sub frmMDI_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If Control.ModifierKeys = Keys.Shift Or Control.ModifierKeys = Keys.Alt Then
'do something
End If
End Sub
This successfully traps if EITHER key is pressed. However, if in order to trap events when BOTH keys are pressed I replace the "Or" with "And", as here:
If Control.ModifierKeys = Keys.Shift And Control.ModifierKeys = Keys.Alt Then
'do something
End If
then NOTHING happens at all. What am I missing here?