<!-- PDF page 94 -->

<table>
<tbody>
<tr><td>bit <strong>5</strong> (value <strong>32</strong>)</td><td><em>fire2</em> pressed</td></tr>
<tr><td>bit <strong>6</strong> (value <strong>64</strong>)</td><td><em>fire3</em> pressed</td></tr>
<tr><td>bit <strong>7</strong> (value <strong>128</strong>)</td><td><em>fire4</em> pressed</td></tr>
</tbody>
</table>

For example:

<table>
<tbody>
<tr><td><code>INPUT 1 &amp; 8</code></td><td>returns <em>false</em> (<strong>0</strong>) if up is not pressed on joystick 1, <em>true</em> (8 is non-zero) if it is</td></tr>
<tr><td><code>INPUT 0 &amp; @11110000</code></td><td>returns <em>false</em> (<strong>0</strong>) if no fire buttons are pressed on joystick 0, <em>true</em> (non-zero) if at least one is</td></tr>
</tbody>
</table>

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

<table>
<tbody>
<tr><td>up</td><td><strong>Q</strong></td></tr>
<tr><td>down</td><td><strong>A</strong></td></tr>
<tr><td>left</td><td><strong>O</strong></td></tr>
<tr><td>right</td><td><strong>P</strong></td></tr>
<tr><td>fire</td><td><strong>SPACE</strong></td></tr>
<tr><td>fire2</td><td><strong>M</strong></td></tr>
<tr><td>fire3</td><td><strong>ENTER</strong></td></tr>
<tr><td>fire4</td><td><strong>X</strong></td></tr>
</tbody>
</table>

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

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

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 **PRINT**able, 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
```

