Top
PowerCOBOL V11.0 Reference
FUJITSU Software

6.24 KeyPress Event

Description:

Generated when a character key is pressed and passed to the control that has the focus.

The event is not generated for non-character keys such as the function keys and the shift keys.

The KeyPress and Key events are usually generated after the KeyDown event.

If a key is pressed, and kept depressed, multiple KeyDown and KeyPress events are generated.

To support special keystrokes, such as short-cuts, on the form, see the PreKeyUp event.

TreeView and
ListView

KeyDown events are not generated when a label is being edited.

Others

Event is not generated in the following cases:

  1. When the Tab key is pressed.

  2. When an access (mnemonic) key is pressed.

  3. If the form contains the following controls, when the ENTER key is pressed:

    • The control that has focus does not use ENTER key
      (e.g. Table control, a TextBox control whose MultiLine property is True, use the ENTER key.)

    • A CommandButton control, whose Default property is True, has the focus.

  4. If there are the following controls on the form, when ESCAPE key is pressed:

    • The control that has focus does not use ESCAPE key.

    • CommandButton control, whose Cancel property is True.

Note that, if the KeyAscii parameter of the PreKeyPress event of the Form object is set to another character code just before the KeyPress event is generated, the KeyAscii parameter of the KeyPress event is the character code that was set in the PreKeyPress event.

Used in controls:

CheckBox

ComboBox

CommandButton

DriveList

Edit

FileList

FolderList

ListBox

ListView

OptionButton

ScrollBar

Slider

Tab

Table

TextBox

TreeView

Used in objects:

Form

Parameters:

1. [VT_I4 - Index S9(9) COMP-5]

2. VT_I2 - KeyAscii S9(4) COMP-5

Description of parameters:

  1. Index: When the control is part of an array, Index contains the control's index in the array.

  2. KeyAscii: The ASCII code of the key that was pressed. See Key Code Constants for details. You can only use the constants POW-KEY-0 to POW-KEY-9 and POW-KEY-A to POW-KEY-Z in the list.