BASIC KEY Functions - fvdhoef/aquarius-plus GitHub Wiki
TYPE: plusBASIC system function
FORMAT: GETKEY
Action: Waits for a key press, then returns the value of that key.
- In ASCII mode, returns the ASCII value of the key pressed.
- In scan-code mode, return the key-down
Note: The GETKEY function causes your plusBASIC program to wait until a key has been pressed. If you need to check for a key press as part of a program loop that performs other tasks while waiting for a key press, use INKEY, below.
TYPE: plusBASIC system function
FORMAT: GETKEY$
Action: As above, but returns a string containing the ASCII character or scan code.
Note: The GETKEY$ function causes your plusBASIC program to wait until a key has been pressed. If you need to check for a key press as part of a program loop that performs other tasks while waiting for a key press, use INKEY$, below.
TYPE: plusBASIC system function
FORMAT: INKEY
Action: Returns the ASCII value of the last key pressed.
- Returns 0 if no key was pressed.
Aquarius ASCII Codes
Dec | Hex | Chr | Dec | Hex | Chr | Dec | Hex | Chr | Dec | Hex | Chr | |||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
32 | 20 | Sc | 64 | 40 | @ | 96 | 60 | ` | 128 | 80 | F1 | |||
33 | 21 | ! | 65 | 41 | A | 97 | 61 | a | 129 | 81 | F2 | |||
34 | 22 | " | 66 | 42 | B | 98 | 62 | b | 130 | 82 | F3 | |||
35 | 23 | # | 67 | 43 | C | 99 | 63 | c | 131 | 83 | F4 | |||
36 | 24 | $ | 68 | 44 | D | 100 | 64 | d | 132 | 84 | F5 | |||
37 | 25 | % | 69 | 45 | E | 101 | 65 | e | 133 | 85 | F6 | |||
38 | 26 | & | 70 | 46 | F | 102 | 66 | f | 134 | 86 | F7 | |||
39 | 27 | ' | 71 | 47 | G | 103 | 67 | g | 135 | 87 | F8 | |||
40 | 28 | ( | 72 | 48 | H | 104 | 68 | h | 136 | 88 | ||||
41 | 29 | ) | 73 | 49 | I | 105 | 69 | i | 137 | 89 | Pause | |||
42 | 2A | * | 74 | 4A | J | 106 | 6A | j | 138 | 8A | PgUp | |||
43 | 2B | + | 75 | 4B | K | 107 | 6B | k | 139 | 8B | PgDn | |||
44 | 2C | , | 76 | 4C | L | 108 | 6C | l | 140 | 8C | ShfTab | |||
45 | 2D | - | 77 | 4D | M | 109 | 6D | m | 141 | 8D | ||||
46 | 2E | . | 78 | 4E | N | 110 | 6E | n | 142 | 8E | CrsrRt | |||
47 | 2F | / | 79 | 4F | O | 111 | 6F | o | 143 | 8F | CrsrUp | |||
48 | 30 | 0 | 80 | 50 | P | 112 | 70 | p | 144 | 90 | F9 | |||
49 | 31 | 1 | 81 | 51 | Q | 113 | 71 | q | 145 | 91 | F10 | |||
50 | 32 | 2 | 82 | 52 | R | 114 | 72 | r | 146 | 92 | F11 | |||
51 | 33 | 3 | 83 | 53 | S | 115 | 73 | s | 147 | 93 | F12 | |||
52 | 34 | 4 | 84 | 54 | T | 116 | 74 | t | 148 | 94 | F13 | |||
53 | 35 | 5 | 85 | 55 | U | 117 | 75 | u | 149 | 95 | F14 | |||
54 | 36 | 6 | 86 | 56 | V | 118 | 76 | v | 150 | 96 | F15 | |||
55 | 37 | 7 | 87 | 57 | W | 119 | 77 | w | 151 | 97 | F16 | |||
56 | 38 | 8 | 88 | 58 | X | 120 | 78 | x | 152 | 98 | ||||
57 | 39 | 9 | 89 | 59 | Y | 121 | 79 | y | 153 | 99 | ||||
58 | 3A | : | 90 | 5A | Z | 122 | 7A | z | 154 | 9A | End | |||
59 | 3B | ; | 91 | 5B | [ | 123 | 7B | { | 155 | 9B | Home | |||
60 | 3C | < | 92 | 5C | \ | 124 | 7C | | | 156 | 9C | ||||
61 | 3D | = | 93 | 5D | ] | 125 | 7D | } | 157 | 9D | Ins | |||
62 | 3E | > | 94 | 5E | ^ | 126 | 7E | ~ | 158 | 9E | CrsrLf | |||
63 | 3F | ? | 95 | 5F | _ | 127 | 7F | Del | 159 | 9F | CrsrDn |
TYPE: BASIC system function
FORMAT: INKEY$
Action: As above, but returns a string containing the ASCII character or scan code.
- Returns an empty string if no key was pressed.
TYPE: plusBASIC system function
FORMAT: LWRKEY
Action: As INKEY, but characters A
through Z
are converted to lowercase.
TYPE: plusBASIC system function
FORMAT: LWRKEY$
Action: As INKEY$, but characters A
through Z
are converted to lowercase.
TYPE: plusBASIC system function
FORMAT: UPRKEY
Action: As INKEY, but characters a
through z
are converted to uppercase.
TYPE: plusBASIC system function
FORMAT: UPRKEY$
Action: As INKEY$, but characters a
through z
are converted to uppercase.
TYPE: BASIC system function
FORMAT: KEY ( keycode )
Action: Returns the state of the specified key.
-
keycode is the key matrix index code of the key to check or
-1
to check all keys. - If the specified key is currently pressed,
-1
is returned, otherwise,0
is returned. - Illegal Quantity error results if keycode is not in the range -1 to 63, inclusive.
Note: keycode is not the same as the ASCII code!
Aquarius Key Codes
Code | Hex | Key | Code | Hex | Key | Code | Hex | Key | Code | Hex | Key | |||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | $00 | = | 16 | $10 | 9 | 32 | $20 | 6 | 48 | $30 | 3 | |||
1 | $01 | BKSP | 17 | $11 | O | 33 | $21 | Y | 49 | $31 | E | |||
2 | $02 | : | 18 | $12 | K | 34 | $22 | G | 50 | $32 | S | |||
3 | $03 | Return | 19 | $13 | M | 35 | $23 | V | 51 | $33 | Z | |||
4 | $04 | ; | 20 | $14 | N | 36 | $24 | C | 52 | $34 | Space | |||
5 | $05 | . | 21 | $15 | J | 37 | $25 | F | 53 | $35 | A | |||
6 | $06 | Insert | 22 | $16 | CsrLf | 38 | $26 | PgUp | 54 | $36 | Menu | |||
7 | $07 | Delete | 23 | $17 | CsrDn | 39 | $27 | PgDn | 55 | $37 | Tab | |||
8 | $08 | - | 24 | $18 | 8 | 40 | $28 | 5 | 56 | $38 | 2 | |||
9 | $09 | / | 25 | $19 | I | 41 | $29 | T | 57 | $39 | W | |||
10 | $0A | 0 | 26 | $1A | 7 | 42 | $2A | 4 | 58 | $3A | 1 | |||
11 | $0B | P | 27 | $1B | U | 43 | $2B | R | 59 | $3B | Q | |||
12 | $0C | L | 28 | $1C | H | 44 | $2C | D | 60 | $3C | Shift | |||
13 | $0D | , | 29 | $1D | B | 45 | $2D | X | 61 | $3D | Ctrl | |||
14 | $0E | CsrUp | 30 | $1E | Home | 46 | $2E | Pause | 62 | $3E | Alt | |||
15 | $0F | CrsRt | 31 | $1F | End | 47 | $2F | PrtSc | 63 | $3F | GUI |
Examples
PRINT KEY(3)
...and keep the RETURN key pressed.
Prints
-1
because the RETURN key was pressed when evaluated.
PRINT KEY(0)
...with no other key pressed.
Prints
0
because the EQUAL key was NOT pressed when evaluated.
100 REM Check for "w" key
200 if key(57) then print "w"
300 print" "
400 goto 100
Prints the letter "w" whenever the "w" key is pressed, and the letters scroll up the screen.
FORMAT: KEY ( keystring )
Action: As above but checks for multiple keys.
- keystring is a binary string of single byte keycodes to check for (see Aquarius Key Codes above).
- Illegal Quantity error results if any keycode is greater than 63.
- Returns the position in the string of the detected key (0 for none).
- If multiple keys are pressed, the first key in the list that is pressed is detected.
Examples
100 REM Check for cursor keys
110 DIM D$(4)="","Up","Down","Right","Left"
120 K=KEY($"0E170F16")
130 IF K THEN PRINT D$(K)
140 GOTO 120
When a cursor key is pressed, prints the key direction to the screen.