Occurs when the user presses and releases a key. You can use the KeyPress event for intercepting keystrokes entered in a control. You can also test keystrokes immediately for validity or format characters as they are typed. Use the KeyPreview property to create global keyboard-handling routines.
PROCEDURE Object.KeyPress LPARAMETERS nKeyCode, nShiftAltCtrl |
Parameters
- nKeyCode
-
Contains a number that identifies the key pressed. For a list of codes for special keys and key combinations, see INKEY( ).
- nShiftAltCtrl
-
Sets a particular bit if a modifier key is held down while pressing the key specified by nKeyCode. Valid modifier keys are the SHIFT, CTRL, and ALT keys.
The following table lists the modifier key values for nShiftAltCtrl.
nShiftAltCtrl Modifier key 1
SHIFT
2
CTRL
4
ALT
This parameter is the sum of the bits with the least-significant bits corresponding to the SHIFT key (bit 0), the CTRL key (bit 1), and the ALT key (bit 2). These bits correspond to the values 1, 2, and 4, respectively. This parameter indicates the state of these keys. Some, all, or none of the bits can be set, indicating that some, all, or none of the keys is pressed. For example, if both CTRL and ALT are pressed, the value of nShiftAltCtrl is 6.