Keystrokes

solus

Freshman
Joined
Apr 5, 2003
Messages
30
Location
Phoenix
How would I link keystrokes to buttons on a form? The windows accessories calculator is a perfect example.
 
Set the form's .KeyPreview = True and then use the KeyUp event to check for the key:

Visual Basic:
Private Sub frmCalculator_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp
    Select Case e.KeyCode
        Case Keys.NumPad0
            MsgBox "You pressed 0 on the number pad"
    End Select
End Sub
 
Back
Top