PreviewKeyDown Event
Description
Occurs immediately before the KeyDown event.
Syntax
Public Event PreviewKeyDown( _
ByRef KeyCode As Integer, _
ByVal Shift As Integer, _
ByRef Cancel As Boolean _
)
Parameters
- KeyCode: ASCII code for the key that was pressed.
- Shift: Specifies whether the Shift, Ctrl, or ALT keys were pressed.
- Cancel: Set to True to cancel the KeyDown event from occurring.
Remarks
The PreviewKeyDown event will occur immediately BEFORE the KeyDown event is fired to give you a chance to cancel or filter a key press if needed.
Any combination of the Shift, Alt, and Ctrl keys can be used. The table below shows the possible values for the Shift parameter:
| Shift Parameter Value | Bit Mask |
|---|---|
| Shift | 001 |
| Ctrl | 010 |
| Shift + Ctrl | 011 |
| Alt | 100 |
| Alt + Shift | 101 |
| Alt + Ctrl | 110 |
| Shift + Alt + Ctrl | 111 |
See Also
Copyright (c) 1998-2024 Codejock Technologies. All rights reserved.