keyDown
keyDown(keyCode: Integer io; (Form) shift: Integer); keyDown(control: control-type input; (Control) keyCode: Integer io; shift: Integer);
The keyDown event occurs when the user presses a key while an object has focus. (To interpret ANSI characters, use the keyPress event.) This event uses the parameters listed in the following table.
Parameter | Description |
---|---|
keyCode | A key code; for example, J_key_F1 (F1 key) or J_key_Home (Home key). |
shift | The state of the Shift, Ctrl, and ALT keys when the key was pressed. This integer is a combination of values, as follows. |
|
|
|
|
|
You can use the Window class constants listed in the following table to test the state of the Alt, Ctrl, and Shift keys of the shift parameter.
Window Class Constant | Bit Value |
---|---|
KeyState_Alt | #4 |
KeyState_Ctrl | #2 |
KeyState_Shift | #1 |
The keyDown event of the Form class first receives all keystrokes for all controls, followed by the object with the focus. Although the keyDown event can apply to most keys, it is most often used for:
-
Extended character keys such as function keys
-
Navigation keys
-
Combinations of keys with standard keyboard modifiers
-
Distinguishing between the numeric keypad and regular number keys
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 keyDown event. (Event methods can be enabled or disabled in standard client mode and in thin client mode.)
Use the keyDown event for keyboard handlers if you need to respond to the pressing of a key.
When using a numeric text box (the inputType property is set to InputType_TextNumeric), the Form and TextBox class keyDown events are still fired when the entered key is invalid. This enables the form to process keys such as the Enter key in the Form::keyDown or keyPress events 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.
Changing the keyCode parameter effects only the Form class. For control classes, Windows has already predetermined the actions taken.