# INKEY

Syntax:

If: inkey = "c"

Then: aa=inkey

Where "c" is a keyboard character or nothing (no key pressed) and where "aa" is the dummy field used to hold the value of the key the user pressed.

Version Ref: 3.x

Description:

Gets next keystroke if available.

INKEY is a system function that returns the value of the first character in the type-ahead buffer. Until a key has been pressed, the value of INKEY is null. On action lines INKEY must be assigned to a field in order to use the key pressed. On condition lines INKEY must be compared to a value; it cannot be used by itself. The condition, "If: inkey", won't work.

For another way of capturing user keystrokes for processing, see the WAITKEY command.

INKEY cannot detect and does not respond to the BREAK key.

IMPORTANT: The INKEY function is CPU intensive. It is STRONGLY suggested that you use the WAITKEY function in its place.

Examples:

Use INKEY to eliminate extra keys the user may have pressed on the way out of Inquire, Update, Add or Request Output. These extra keystrokes are sometimes accepted by menus, and send the user into unwanted situations. Use this syntax to eliminate extra keystrokes:

loop If: inkey ne ""
Then: goto loop

In other words, keep resetting INKEY until it has no value (is null ""). When INKEY becomes null, the loop ends.

To continuously show the time at the top-right corner of the screen until the user presses a key:

loop If: inkey eq ""
Then: show (1,70) @TM; goto loop

Use @SK with INKEY to test whether the user wants help:

If: inkey eq "?" or @sk eq "HELP"
Then: help "field1"