71 100 PRINT "DO YOU WANT TO GO ON" 110 PRINT "YOU HAVE 2 SECONDS TO REPLY" 120 A=INKEY(200) 130 IF A=-1 THEN PRINT "TOO LATE YOU MISSED IT" 140 IF A=89 THEN PRINT "COURAGEOUS FOOL!" 150 IF A=78 THEN PRINT "COWARD" You will see that ‘no reply’ returns the value -1 when using INKEY and returns an empty string when using INKEY$ . Advanced features Another important use of INKEY and GET is with the group of four direction keys at the top of the keyboard. Normally these are used for editing, but a special statement can make these keys produce ASCII codes like all the other keys on the keyboard.
They can then be used by a program for some special purpose – for example to move a point around the screen. The statement *FX 4,1 makes the editing keys produce ASCII codes and the statement *FX 4,0 returns the keys to their editing function. The keys produce the following codes: COPY 135 or (&87) 8 136 or (&88) : 137 or (&89) ; 138 or (&8A) 9 139 or (&8B) For example: 10 *FX 4,1 20 MODE4 30 X=500 40 Y=500 50 REPEAT 60 PLOT 69,X,Y 70 K=GET 80 IF K=136 THEN X=X-4 90 IF K=137 THEN X=X+4 100 IF K=138 THEN Y=Y-4 110 IF K=139 THEN Y=Y+4 120 UNTIL Y=0 130 *FX 4,0 This program waits at line 70 for a key to be pressed.
The program shown above would often be part of a much larger program in which case you would not want everything to stop until a key is pressed. Here it would be better to use K=INKEY(0) at line 70 which will let the computer have a quick look to see if a key has been pressed but not wait at all.