KeyUp Event

Applies to:  KeyboardEvents object
See also:  KeyDown event

Occurs when a key is released.

Syntax:

Public Event KeyUp(ByVal KeyCode As Integer, ByVal Shift As Boolean, ByVal Control As Boolean, ByVal Alt As Boolean, ByRef Cancel As Boolean)

The KeyUp 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.
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 KeyUp event occurs after the KeyDown event.  Although setting Cancel = True will prevent the KeyUp event from being processed, it is better to do this in the KeyDown event, as cancelling the KeyDown event will cancel both the KeyDown and KeyUp events.

Example:

Trapping Keyboard Events 

 

Home Copyright and Disclaimer