Personal Computer News


Spectrum Key Considerations

 
Published in Personal Computer News #051

Spectrum Key Considerations

When writing an educational program or a program for users not familiar with the Spectrum's quirks, a 'Press any key' routine can be puzzling if it does not recognise every key:

10 IF INKEY$="" THEN GOTO 10

does not recognise any of the shift keys.

This can be resolved using IN statements as shown below. This will recognise all keys and can be incorporated into your own programs.

100 PRINT"Press any key"
110 IF INKEY$<>""OR IN 65278=254 OR IN 32766=253 THEN GOTO 200
120 GOTO 110
200 PRINT"Key pressed"

Peter Dans
Lowestoft, Suffolk

Note that some Spectrums may need to alter line 110 so that 65278=190 and 32766=189.

Peter Dans