keyPress
keyPress(keyCharCode: Integer io); (Form) keyPress(control: control-type input; (Control) keyCharCode: Integer io);
The keyPress event occurs when the user presses and releases an ANSI key.
The keyPress event uses the parameter listed in the following table.
Parameter | Description |
---|---|
keyCharCode | Returns a standard numeric ANSI key code. The keyCharCode parameter is passed by reference; changing it sends a different character to the object. (See the global constants in the |
Changing the value of the keyCharCode parameter changes the character that is displayed. Changing the keyCharCode parameter to zero (0) cancels the keystroke so that the object receives no character.
The form first receives the keyPress event and then the object with the focus. A keyPress event can involve any printable keyboard character, the Ctrl key combined with a character from the standard alphabet or a special character, and the Enter or Backspace key. Use a keyPress event for intercepting keystrokes entered in a text box or combo box. It enables you to immediately test keystrokes for validity or to format characters as they are typed.
Use the keyDown and keyUp events to handle any keystroke not recognized by the keyPress event; for example, function keys, editing keys, navigation keys, and any combinations of these with keyboard modifiers. Unlike the keyDown and keyUp events, the keyPress event does not indicate the physical state of the keyboard but passes a character.
Use the Window class enableEvent method to control at run time whether JADE logic associated with an event for a specific form or control is executed. You could use this method in thin client mode, for example, to speed up the data entry process for a TextBox control by disabling the keyPress event. (Event methods can be enabled or disabled in standard client mode and in thin client mode.)
When using a numeric text box (the inputType property is set to InputType_TextNumeric), the Form class keyPress event is still fired when the entered key is invalid. This enables the form to process keys such as the Enter key in the keyDown or keyPress events of the Form class and the control to process these keys in its keyDown event, therefore allowing application users to use the numeric keypad when a form requires a large amount of numeric data entry.
The keyPress event interprets the uppercase and lowercase of each character as separate key codes, and therefore as two separate characters.
The keyDown and keyUp events interpret the uppercase and lowercase of each character by means of two parameters: keyCode, which indicates the physical key (therefore returning "A" and "a" as the same key), and shift, which indicates the state of Shift+ key and therefore returns "A" or "a".