Function to return key press
The INKEY() function returns zero if no key has been pressed on the keyboard, or a non-zero value which is the ASCII code for the key if one has been pressed.
If the optional parameter <expN> is included then the INKEY() function will wait <expN> number of seconds for a key to be pressed. If no key is pressed during that time, the program will continue to execute and INKEY() will return a value of 0. If a key is pressed during the specified time, the program will continue to execute and INKEY() will return the ASCII code for the key pressed.
If the value of zero is specified for <expN>, then the INKEY() function will wait until a key is pressed on the keyboard. The command SET PCKEYS is used to change the return value of the INKEY() function. If it is set ON, then the return value will match an IBM PC keyboard. If INKEYDELAY is set OFF, then DO WHILE loops that wait for user input with the INKEY() function may be very CPU intensive. The SET INKEYDELAY command controls the wait period for the INKEY() function.
A second parameter, <expC> is available in Recital Mirage. If <expC> is equal to "M", the INKEY() function will trap and return mouse clicks. The numeric value returned indicates the mouse operation.
|INKEY() Return Value||Mouse Operation|
INKEY(<expN>,"M") can also be used in conjunction with the ON MOUSE command to run a command when a mouse operation takes place. The command run can be a call to a procedure or User Defined Function if required. The MROW() and MCOL() functions can be called to determine the current row and column positions at the time of the mouse operation. The LASTKEY() function can be called to determine the type of operation. LASTKEY() returns the same numeric values for mouse operations as shown in the table above.
do while inkey()=0 @0,68 say ampm() sleep 2 enddo // Another Example ? "Press any key..." ch = inkey(0)