GETKEY

The GETKEY function retrieves any keyboard input from the user that is available. If no keypress is available it will return zero.

Inside XJDeveloper, XJRunner and XJInvestigator keypresses like function keys, cursor keys and control characters are not passed through to the XJEase runtime. Input is limited to printable characters plus Space (0x20), Backspace (0x8) and Enter (0xD).

When running on the command line with XJRun, all ASCII characters including control characters are available. The only exception is Ctrl + C, which is used to terminate the program.

Previous versions of XJTAG allowed GETKEY to be called without any brackets. Support for this usage was removed in XJTAG v4.0.

Syntax

GETKEY()

Return value

An INT value containing the next character that has been pressed, or zero if no keypress is available.

Example

LOCAL FlashWait()()
  INT key;
  INT colour := 1;

  PRINT("LED will flash until key is pressed.\n");

  DO
    CALL("D1", "SetLED")(colour)();
    key := GETKEY();
  WHILE key = 0
    colour := colour + 1;
    IF colour = 3 THEN
      colour := 0;
    END;
  END;
END;