Share via


BeforeKeyPress Event

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Occurs when a user presses and releases a key on the keyboard, but before the control has processed the keystroke. If the user holds the key down, this event repeats itself at the key-repeat interval that has been set on the user’s computer.

Private Sub Object_BeforeKeyPress(ByValKeyAsciiAsLong, ByValCancelAsByRef)

Object   A ChartSpace, PivotTable, or Spreadsheet object.

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

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

Remarks

Canceling this event does not prevent the KeyPress or KeyUp events from firing.

The sequence of keyboard-related events is:

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