lastKeyTyped()

You can use the consoleLib.lastKeyTyped() system variable to obtain, as an INT, the code point (numeric representation) of the last key that was pressed on the keyboard. The code point depends 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 differs from consoleLib.getKey() in that it does not read a key from input.

Syntax

  consoleLib.lastKeyTyped( )
  returns (result INT)
result
An integer that represents the last key pressed.

Example

In the following example, the program checks for an exit request from the user.

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

Feedback