KeyPress Event

Occurs whenever the user presses and releases a key on the keyboard.

Private Sub Object_KeyPress(ByValKeyAsciiAsLong)

*Object    * The name of the ChartSpace, PivotTable or Spreadsheet object that you are trapping this event for.

KeyAscii A Long that represents the key code of the key that was pressed or released.


This event will not be called if the BeforeKeyDown event is cancelled.

For information about using events with VBScript, see Declaring and Using Event Procedures in VBScript .

The sequence of keyboard-related events is:

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

Applies to | ChartSpace Object | PivotTable Object | Spreadsheet Object

See Also | BeforeKeyDown Event | BeforeKeyPress Event | BeforeKeyUp Event | KeyDown Event | KeyUp Event