Detecting Tab Key

G

Guest

How do I determine if the user has pressed the tab key? The Keypress and Keydown events fire for other keys, but not the tab.
 
H

Herfried K. Wagner [MVP]

* "=?Utf-8?B?Q2hhcmxpZQ==?= said:
How do I determine if the user has pressed the tab key? The Keypress
and Keydown events fire for other keys, but not the tab.

\\\
Protected Overrides Function ProcessDialogKey(ByVal keyData As System.Windows.Forms.Keys) As Boolean
If keyData = Keys.Tab Then
MsgBox("Pressed")
End If
MyBase.ProcessDialogKey(keyData)
End Function
///
 
B

Bernie Yaeger

Hi Charlie,

If you set the form's keypreview property to true, you will trap the tab key
in the keyup event of the form.

HTH,

Bernie Yaeger

Charlie said:
How do I determine if the user has pressed the tab key? The Keypress and
Keydown events fire for other keys, but not the tab.
 
H

Herfried K. Wagner [MVP]

Bernie,

* "Bernie Yaeger said:
If you set the form's keypreview property to true, you will trap the tab key
in the keyup event of the form.

Only if there are no controls on the form, all controls are disabled or
the controls don't have tabstops.
 
B

Bernie Yaeger

Hi Herfried,

No, I tested it on a form with controls, some of which were tabstops and not
disabled.

Bernie
 

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