ON_KEY_DOWN

ON_KEY_DOWN N,L

EXECUTES THE PROGRAM FROM LABEL L WHEN THE USER PRESSES ANY KEY WHILE THE SYSTEM OBJECT NUMBER N HAS FOCUS

  • Type: Command
  • Parameters: 2
  • Group: Events

ACTION

The command ON_KEY_DOWN N,L assigns a label (which must be defined in the program) from which the program will run every time the user presses any key of the keyboard, while the system object designated by the number N has focus.

The system object must be one of the following types: BUTTON, EDIT, MEMO, COMBO, FORM, LIST, CHECK, OPTION, SPIN, GRID, MEMO_RICH, BUTTON_PICTURE, SCENE2D, GRID_DRAW, SYNEDIT.

SYNTAX: ON_KEY_DOWN N,L

  • N = system object number (integer or real). Must be greater than 0 and less than or equal to the allowed maximum number of system objects.
  • L = Label.

USE

  • The command ON_KEY_DOWN is used to associate an event (KEY_DOWN) happening to a system object, to a program location (defined by the label L).
  • When the event occurs, the program named by the label is executed.

ERROR

  • If number N is not a correct expression.
  • If number N exceeds the allowed maximum number of system objects.
  • If number N is less than 0.
  • If system object number N does not exist.
  • If system object number N is not of the type : BUTTON, EDIT, MEMO, COMBO, FORM, LIST, CHECK, OPTION, SPIN, GRID, MEMO_RICH, BUTTON_PICTURE, SCENE2D, GRID_DRAW, SYNEDIT.
  • If the label L does not exist.
  • If L is not a correct label name.

EXAMPLE

rem declare a label

label enter_key

rem an EDIT is created

edit 1

rem every time a key is released in EDIT, execute from label "enter_key"

on_key_up 1,enter_key

end: rem main program is finished

enter_key:

rem treatment of event

if key_up_code=13 then caption 0,"ENTER is pressed"

return

SEE ALSO

KEY_DOWN_CODE

KEY_DOWN_SPECIAL

KEY_UP_CODE

KEY_UP_SPECIAL

ON_KEY_UP