KeyPress

This event occurs when the user presses and releases an ANSI key.

Syntax

Private Sub object_KeyPress(keyascii)

Parameters

object
Object expression that evaluates to a control or Form object.
keyascii
Integer that returns a standard numeric ANSI keycode.

Remarks

The keyascii parameter is passed by reference; changing it sends a different character to the object. Changing keyascii to 0 cancels the keystroke so that the object receives no character.

If the KeyPreview property is set to True, a form receives the event before controls on the form receive the event. Use the KeyPreview property to create global keyboard-handling routines.