Top
PowerCOBOL V11.0 Reference
FUJITSU Software

6.36 PreKeyDown Event

Description:

Generated when a key is pressed before the KeyDown event is passed to the control that has the focus.

The PreKeyDown, PreKeyPress, and PreKeyUp events enable you to take action on special keys, such as short-cut keys (e.g. Ctrl + D).

If no control has the focus then the PreKeyDown event is not generated - the Form only receives the KeyDown event.

The PreKeyDown event is generated before the KeyDown event, and hence usually before the PreKeyPress, KeyPress, PreKeyUp, and KeyUp events.

If a key is pressed and kept depressed, multiple PreKeyDown, KeyDown, PreKeyPress and KeyPress events are generated before the PreKeyUp and KeyUp events.

Note that if you press a toggle key (e.g. Caps Lock, Num Lock):

  • The order of events may be changed.

  • One of these events may not be generated.

If the active window is changed in the PreKeyDown event, like a message box displayed by DisplayMessage, the value of the ShiftState parameter in the next event (such as KeyDown or CommandButton Click) is different from the key you input. For example,

  1. In the PreKeyDown event, a message box is displayed when it recognizes that you pressed the [Shift+F5] key. Then, in the KeyDown event, the ShiftState parameter is zero unless you keep pressing the [Shift] key at the same time as pushing a button that closes the message box.

  2. Suppose that a CommandButton is operated by the [F5] key and a message box is displayed in the PreKeyDown event when you press the [Shift+F5] key. The Click event of the CommandButton is generated unless you are pressing the [Shift] key when you push one of the buttons that closes the message box.

  3. Similarly, suppose the CommandButton is operated by the [Shift+F5] key and a message box is displayed in the PreKeyDown event when you press the [Shift+F5] key. The Click event of the CommandButton is NOT generated unless you keep pressing the [Shift] key when you push one of the buttons to close the message box.

Used in controls:

None.

Used in objects:

Form

Parameters:

1. VT_I2 - KeyCodeS9(4) COMP-5

2. VT_I2 - ShiftStateS9(4) COMP-5

Description of parameters (with constants):

KeyCode: The key code that was pressed. See Key Code Constants for details of key codes.

ShiftState: Bit mask settings indicate the state of each of the shift keys - Shift, Ctrl and ALT. Numbering the bits 1 to 8, from least significant to most significant, the bit mapping is:

1 - Shift key(POW-SHIFTSTATE-SHIFT)

2 - Ctrl key(POW-SHIFTSTATE-CTRL)

3 - Alt key(POW-SHIFTSTATE-ALT)

For example if the parameter has a value of 6 (binary 00000110), this indicates that the Ctl and Alt keys are depressed.