Detecting Keypress + Modifier (Alt, Ctrl, Shift)

This short code example shows how to detect a key + modifier key combination (like ALT + A) and do something with it.

 

Related Articles

... and you 'll find more on the NET Development Menu

Private Sub MasterOrdersRapidEntry_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
    If e.Modifiers = Keys.Alt Then
        Select Case e.KeyCode
            Case Keys.N
                'Alt + N
                If Me.btnMasterNew.Enabled Then
                    e.Handled = True
                    btnMasterNew_Click(New System.Object, New System.EventArgs)
                End If
            Case Keys.A
                'Alt + A
                If Me.btnAddressLookup.Enabled Then
                    e.Handled = True
                    AddressLookup()
                End If
            Case Keys.I
                'Alt + I
                e.Handled = True
                CreateNewItem()
        End Select
    End If
End Sub

RealWorldCode gives developers practical, real‑world solutions with clean, working code — no fluff, no theory, just answers.
Links
Home
Knowledge Areas
Sitemap
Contact
Et cetera
Privacy Policy
Terms and Conditions
Cookie Preferences