INKEY
Jump to navigation
Jump to search
INKEY, INKEY$[edit]
Syntax[edit]
INKEY($)
Description[edit]
These functions return the value of any key which is pressed down when the INKEY function is used, or has been pressed since the previous INKEY/INKEY$. The key is returned as either its ASCII value (INKEY) or its character (INKEY$). INKEY returns -1 if no key is pressed. The ASCII value is the numeric value associated with each key by the computer. INKEY$ returns a blank string if no key has been pressed.
Note The function only works when the cursor is in the text window. Click the cursor in the text window before pressing a key.
Examples[edit]
Print SENSOR A until the space-bar is pressed
REPEAT PRINT SENSOR A UNTIL INKEY = 32
Move a buggy forward when the ‘F’ key is pressed
REPEAT IF INKEY$ = "F" THEN FORWARD A ELSE HALT A FOREVER