Changes the keyboard mapping to execute a command when a specified key or key combination is pressed.

Syntax

ON KEY [LABEL <key label>] [<command>]

LABEL <key label>

Identifies the key or key combination that, when pressed, causes <command> to execute. Without LABEL <key label>, dBASE Plus executes <command> when you press any key. ON KEY LABEL is not case-sensitive.

<command>

The command that is executed when you press the key or key combination. If you omit <command>, the command previously assigned by ON KEY is disabled.

Description

Each key on the keyboard has a default meaning or mapping. For alphanumeric keys, this mapping simply types the character. Function keys have predefined actions. The Esc key terminates program execution. Use ON KEY to specify a command that executes when the user presses a key or key combination, overriding the default mapping.

Actions defined by ON KEY will interrupt programs, but not commands; in a program, the ON KEY action will occur after the current command has completed and then the program will continue. ON KEY also doesn't affect the execution of some commands or functions that are specifically looking for keystrokes, such WAIT or INKEY( ). On the other hand, if you KEYBOARD a key that has been remapped, the remapped behavior will occur.

When you issue both ON KEY LABEL <key label> <command> and ON KEY <command>, the key or key combination you specify with ON KEY LABEL <key label> <command> takes precedence and executes its associated <command>. This way you can define actions for specific keys, and a default global action for all other keys. There may be only one ON KEY specification for each specific key and one global action defined at a given time.

ON KEY without arguments removes the effect of all previously-entered ON KEY <command> commands, with or without a LABEL.

To change the default Escape behavior, which interrupts the currently executing program or command, use ON ESCAPE. If both ON KEY and ON ESCAPE are in effect, ON KEY takes precedence when Esc is pressed. In other words, while ON ESCAPE changes the Escape behavior, ON KEY changes the meaning of the Esc key, so that pressing it no longer causes that Escape behavior. While the Escape behavior affects only programs or commands that are executing, ON KEY works at all times.

To assign strings to function keys, use SET FUNCTION. If both ON KEY on SET FUNCTION are in effect, ON KEY takes precedence.

ON KEY LABEL

The <key label> for the standard alphanumeric keys is simply the character on that key, for example, A, b, 2, or @. Use the following key label names to assign special keys or key combinations with ON KEY LABEL <key label>.

Key identification

<key label>

Backspace

Backspace

Back Tab

Backtab

Delete

Del

End

End

Home

Home

Insert

Ins

Page Up

PgUp

Page Down

PgDn

Tab

Tab

Left arrow

Leftarrow

Right arrow

Rightarrow

Up arrow

Uparrow

Down arrow

Dnarrow

F1 to F12

F1, F2, F3, ...

Control+<key>

Ctrl-<key> or Ctrl+<key>

Shift+<key>

Shift-<key> or Shift+<key>

Alt+<key>

Alt-<key> or Alt+<key>

Enter

Enter

Escape

Esc

Space bar

Spacebar