getKey()

The consoleLib.getKey() system function waits for a key to be pressed and returns the code point (numeric representation) of that character as an INT, based on the local character set where the function runs. In ASCII environments, the function returns the ASCII code for the key; in EBCDIC environments, it returns the EBCDIC code. This function reads a key from the input. Results can be interpreted in a portable way by comparing the result with the value returned by consoleLib.getKeyCode().

Syntax

  consoleLib.getKey( consoleField ANY in )
  returns (result STRING)
result
An integer that represents the code point for the key pressed.

Example

The following example determines whether the user pressed the "x" key:

v1 INT;
v1 = consoleLib.getKey();
// "x" exits
if (v1 == consoleLib.getKeyCode("KEY_x"))
  exit program;
end

Feedback