Applies to: KeyboardEvents
object
See also: KeyUp event
Occurs when a key is pressed. The key press may be the result of the
user physically pressing the key, or may result from the keyboard's auto-repeat
feature.
Syntax:
Public Event KeyDown(ByRef
Window As Window, ByVal KeyCode
As Integer, ByVal AutoRepeat
As Boolean, ByVal Shift
As Boolean, ByVal Control
As Boolean, ByVal Alt
As Boolean, ByRef Cancel
As Boolean)
The KeyDown event syntax has these parts:
Part |
Description |
object |
The name of a KeyboardEvents object. NB: object must be declared using WithEvents. |
Window |
A Window object representing the
window which has the input focus. |
KeyCode |
An integer value representing the ASCII code of the key being pressed,
or a virtual key code if the key does not represent an ASCII character. |
AutoRepeat |
A boolean value indicating whether the event is the result of the
keyboard's auto-repeat feature. |
Shift |
A boolean value indicating the state of the shift key. A value of True
indicates that the shift key is down. |
Control |
A boolean value indicating the state of the ctrl key. A value of True
indicates that the ctrl key is down. |
Alt |
A boolean value indicating the state of the alt key. A value of True
indicates that the alt key is down. |
Cancel |
A boolean value that determines whether the window which currently has
keyboard focus will receive this event. Setting Cancel to True prevents the
key press from being processed. |
Remarks:
The KeyDown event is triggered prior to processing by the application in
which the key was pressed.
Example:
Trapping keyboard events
|