Bound Object Frame Control, Check Box Control, Combo Box Control, Command Button Control, Form, List Box Control, Option Button Control, Text Box Control, Toggle Button Control.
These events occur:
Note The KeyDown and KeyUp events apply only to forms and controls on a form.
For both events, the object with the focus receives all keystrokes. A form can have the focus only if it has no controls or all its visible controls are disabled.
A form will also receive all keyboard events, even those that occur for controls, if you set the KeyPreview property of the form to Yes. With this property setting, all keyboard events occur first for the form, and then for the control that has the focus. You can respond to specific keys pressed in the form, regardless of which control has the focus. For example, you may want the key combination CTRL+X to always perform the same action on a form.
If you press and hold down a key, the KeyDown event occurs repeatedly until you release the key, then the KeyUp event occurs.
Although the KeyDown and KeyUp events occur when most keys are pressed, they are typically used to recognize or distinguish between:
The KeyDown and KeyUp events don’t occur when you press:
The ESC key if the form has a command button for which the Cancel property is set to Yes.
Note To find out the ANSI character corresponding to the key pressed, use the KeyPress event.
The KeyDown and KeyPress events occur when you press or send an ANSI key. The KeyUp event occurs after any event for a control caused by pressing or sending the key. If a keystroke causes the focus to move from one control to another control, the KeyDown event occurs for the first control, while the KeyPress and KeyUp events occur for the second control.
Change Event; Enter, Exit Events; GotFocus, LostFocus Events; KeyPress Event; KeyPreview Property; NotInList Event; SendKeys Action; SendKeys Statement.