Capturing control keys

J

John

Hi

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

Thanks

Regards
 
K

kimiraikkonen

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
 
C

Cor Ligthert[MVP]

\\\
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top