Skip to content

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 1
Ctrl 2
Shift + Ctrl 3
Alt 4
Alt + Shift 5
Alt + Ctrl 6
Shift + Alt + Ctrl 7

See Also


Copyright (c) 1998-2024 Codejock Technologies. All rights reserved.