This documentation is archived and is not being maintained.

BeforeKeyUp Event

Office 2003

Occurs when a user releases a key on the keyboard, but before the control has processed the keystroke.

Private Sub Object_BeforeKeyUp(ByVal KeyCode As Long, ByVal Shift As Long, ByVal Cancel As ByRef)

Object    The name of the ChartSpace, PivotTable, or Spreadsheet object that this event applies to..

KeyCode    An integer that represents the key code of the key that was pressed or released.

Shift    The state of the SHIFT, CTRL, and ALT keys. Returns 1 if the SHIFT key was pressed, 2 if the CTRL key was pressed, and 4 if the ALT key was pressed. Returns 0 if neither the SHIFT, CTRL, or ALT keys were pressed.

Cancel    Set the Value property of this object to True to cancel the keystroke.


Canceling this event does not prevent the KeyUp event from firing.

The sequence of keyboard-related events is:

  1. BeforeKeyDown
  2. KeyDown
  3. BeforeKeyPress
  4. KeyPress
  5. BeforeKeyUp
  6. KeyUp