Is there a form KeyPreview event in VB6?


I'd like to capture keys being pressed before they go into a controll (ie. text box, grid, etc.)

Example code that doesn't work is as follows:

Create a new project, a new form, and place a text control with default name 'Text1'

place this code in the form:
Private Sub Form_KeyPress(KeyAscii As Integer)
   MsgBox Chr$(KeyAscii)
End Sub

Who is Participating?
Éric MoreauSenior .Net ConsultantCommented:
Yes it is working but you have to set the form's KeyPreview property to True
No, The Form _KeyPress event is only possible if the Form itself has the focus. If there any controls on the form that can receive the focus, then the form cannot be in focus.
StevenLogicAuthor Commented:
Great.  Thanks.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.