Keyboard events occur for forms and controls when you press keys or send keystrokes while the form or control has the focus. Mouse events occur for forms, form sections, and controls on forms when you press the mouse buttons while the mouse pointer is on a form, section, or control, or when you move the mouse pointer over a form, section, or control.
When you press and release a key while a control on a form has the focus (or use the SendKeys action or statement to send a keystroke), the following sequence of events occurs:
KeyDown Þ KeyPress Þ KeyUp
When you press and release a key or send a keystroke in the ANSI character set key, the KeyDown, KeyPress, and KeyUp events all occur. If you press and hold down an ANSI key, the KeyDown and KeyPress events alternate repeatedly (KeyDown, KeyPress, KeyDown, KeyPress, and so on) until you release the key; then the KeyUp event occurs. For lists of characters in the ANSI character set, click and .
If you press and release a non-ANSI key, the KeyDown and KeyUp events occur. If you press and hold down a non-ANSI key, the KeyDown event occurs repeatedly until you release the key; and then the KeyUp event occurs.
If pressing a key triggers another event for a control, the other event occurs after the KeyPress event but before the KeyUp event. For example, if a keystroke changes text in a text box, triggering a Change event, the following sequence of events occurs:
KeyDown Þ KeyPress Þ Change Þ KeyUp
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. For example, if you change data in a control and then press the TAB key to move to the next control, the following sequences of events occur:
KeyDown Þ BeforeUpdate Þ AfterUpdate Þ Exit Þ LostFocus
Enter Þ GotFocus Þ KeyPress Þ KeyUp
When you press and release a mouse button while the mouse pointer is on a control on a form, the following sequence of events occurs for the control:
MouseDown Þ MouseUp Þ Click
If a control has the focus and you click another control to move the focus to this second control, the following sequences of events occur:
Exit Þ LostFocus
Enter Þ GotFocus Þ MouseDown Þ MouseUp Þ Click
If you move to another record and then click a control, the Current event for the form also occurs before the Enter event for the control.
Double-clicking a control causes both DblClick and Click events to occur. For example, when you double-click a control other than a command button, the following sequence of events occurs for the control:
MouseDown Þ MouseUp Þ Click Þ DblClick Þ MouseUp
When you double-click a command button, these events occur, followed by a second Click event.
The MouseMove event for a form, section, or control occurs when you move the mouse pointer over the form, section, or control. This event is independent of the other mouse events.
For more information on keyboard events, click .
For more information on mouse events, click .