bit 5 (value 32)fire2 pressed
bit 6 (value 64)fire3 pressed
bit 7 (value 128)fire4 pressed

For example:

INPUT 1 & 8returns false (0) if up is not pressed on joystick 1, true (8 is non-zero) if it is
INPUT 0 & @11110000returns false (0) if no fire buttons are pressed on joystick 0, true (non-zero) if at least one is

The default keyboard joystick is set up to use the following keys:

upQ
downA
leftO
rightP
fireSPACE
fire2M
fire3ENTER
fire4X

The keyboard joystick may be redefined with the INPUT function by if negative values are specified for n, as follows:

INPUT -1waits for a key to be pressed and assigns to right
INPUT -2waits for a key to be pressed and assigns to left
INPUT -3waits for a key to be pressed and assigns to down
INPUT -4waits for a key to be pressed and assigns to up
INPUT -5waits for a key to be pressed and assigns to fire
INPUT -6waits for a key to be pressed and assigns to fire2
INPUT -7waits for a key to be pressed and assigns to fire3
INPUT -8waits for a key to be pressed and assigns to fire4
INPUT -9(or any other negative value) clears all assignments

The return value is the character code of the key pressed, which can be useful if you want to display the key just defined (although some special keys have codes below ASCII 32 which aren't PRINTable, so care should be taken). Here's an example on how to set up the keyboard joystick. Note that we cannot use INPUT to print on the screen so separate PRINT statements are needed!

100 x=INPUT -9:
110 ;clear the "keyboard joystick"
120 PRINT "Press a key for right"
130 x=INPUT -1
140 PRINT "Press a key for left"
150 x=INPUT -2
160 PRINT "Press a key for down"
170 x=INPUT -3
180 PRINT "Press a key for up"
190 x=INPUT -4
200 PRINT "Press a key for fire"
210 x=INPUT -5
220 REM Can leave additional fire
    buttons undefined if they aren't
    needed

ZX Spectrum Next User Manual, 3rd Edition (ISBN 978-1-5272-5496-1), written and illustrated by Phoebus R. Dokos. Copyright © 2020-2024 Phoebus Dokos / SpecNext Ltd. Licensed under CC BY-NC-SA 4.0. This is a transcription and can contain errors; check any doubt against the printed page.