Capturing control keys

  • Thread starter Thread starter John
  • Start date Start date
Hi

How can I capture control keys Ctrl-A, Ctrl-B, Ctrl-C etc. in a form?

Thanks

Regards

John,
First set keypreview property of your form to "True", then:

Private Sub Form1_keydown(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.KeyData = Keys.Control + Keys.A Then
MsgBox("Ctrl+A pressed")
ElseIf e.KeyData = Keys.Control + Keys.B Then
MsgBox("Ctrl+B pressed")
ElseIf e.KeyData = Keys.Control + Keys.C Then
MsgBox("Ctrl+C pressed")
End If

Hope this helps,

Onur Güzel
End Sub
 
\\\
Private Sub Form1_KeyUp(ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyEventArgs)
Handles Me.KeyUp
Dim i = e.KeyData
End Sub
///

Cor
 
Back
Top