Microsoft KB Archive/80286

= BUG: TAB Character Can Incorrectly Cause KeyUp/KeyDown Events =

Article ID: 80286

Article Last Modified on 12/12/2003

-

APPLIES TO


 * Microsoft Visual Basic 2.0 Standard Edition
 * Microsoft Visual Basic 3.0 Professional Edition
 * Microsoft Visual Basic 2.0 Professional Edition
 * Microsoft Visual Basic 3.0 Professional Edition
 * Microsoft Visual Basic 1.0 Standard Edition

-



This article was previously published under Q80286





SYMPTOMS
Under certain circumstances, the TAB key may generate either or both a KeyDown or KeyUp event for a form or control. The Language Reference for Visual Basic version 1.0 states on page 160 that KeyDown and KeyUp events are not generated for the TAB key. This is normally true.



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.



MORE INFORMATION
The TAB key is normally used to switch focus from one control to another in the predefined tab order. This action does not normally produce a KeyDown or KeyUp event. However, if there is not another control that can accept the focus, pressing TAB generates a KeyUp and/or KeyDown event. This problem manifests itself in several situations:


 * A form with no controls
 * A form with only one control
 * A form with all controls disabled (or all except one)
 * A form with all controls invisible (or all except one)
 * A combination of the last two above

Steps to Reproduce Problem
 Start Visual Basic, or if it is already running, choose New Project from the File menu. Form1 is created by default. Draw a command button on Form1.  Add the following code to the KeyDown event for the command button: Form1.Print KeyCode  Run the program. Press the TAB key. The character 9 will appear on the form. The character 9 is the ANSI code for the TAB character. End the program.</li></ol>

The TAB key should never produce a KeyDown or KeyUp event. However, because this is a problem that may be corrected in future versions, you should not write code that depends upon this behavior.

Additional query words: buglist1.00 buglist2.00 buglist3.00 2.00 3.00

Keywords: kbbug KB80286

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.