Function Inkey() Foundation
Reads the next character in the keyboard buffer and removes it from the buffer.
Inkey( [<nSeconds>] ) --> nInkeyCode
The return value of Inkey() is an integer in the range of -47 to 422. This value identifies the key taken from the keyboard buffer. When the keyboard buffer has no value (no key has been pressed), Inkey() returns zero.
The function Inkey() is a compatibility function which checks the keyboard buffer but is limited in scope. The function AppEvent() should be used instead of Inkey() in the Xbase++ system. AppEvent() processes mouse events as well as keyboard events.
Inkey() removes the next key code (value of the next key pressed) from the keyboard buffer and returns it. This value is stored internally and can be rechecked with the function LastKey() (last key pressed). When no values are in the keyboard buffer and the argument <nSeconds> contains a value, Inkey() waits a maximum of <nSeconds> seconds for a new keypress. When the value for <nSeconds> equals 0, Inkey() waits until a key is pressed.
The functions Inkey(), LastKey() and NextKey() all retrieve keyboard input. Inkey() reads the next keypress and removes it from the keyboard buffer. NextKey() reads the next keypress without removing it from the keyboard buffer. LastKey() returns the last keypress removed from the keyboard buffer.
Symbolic constants are defined in the header file "Inkey.ch" for all key codes which are returned from Inkey()
A DO WHILE loop like this, where the keyboard is continuously polled, makes use of substantial system resources and impedes other processes because they cannot take advantage of the time when no key is being pressed. Instead of a loop like the one shown above, the following structure is preferable in Xbase++.
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.