KEYBOARD CODES

page · Also: KEYBOARD CODES, Keyboard Scan Codes, SCAN CODES

Keyboard Codes

KEYDOWN() and INKEY$ use Colour Maximite 2 character codes, not PC/AT scan codes. Printable keys return their ASCII code; Escape is 27, Enter is 10 and the arrow keys are:

Up 128 Down 129 Left 130 Right 131

The numeric keypad reports the same code as its top-row equivalent, so keypad 5 is 53 (“5”) and keypad Enter is 10.

KEYDOWN(0) is the number of keys currently held. KEYDOWN(n) for n = 1..KEYDOWN(0) returns the code of the nth held key. This list contract is how CMM2 games poll held keys.

INKEY$ additionally returns Insert 132, Home 134, End 135, PageUp 136, PageDown 137, Delete 127 and F1-F12 145-156.

See also KEYDOWN, INKEY$ and ASCII CHARACTER CODES.

Example:

FOR i = 1 TO KEYDOWN(0)
  IF KEYDOWN(i) = 130 THEN PRINT "LEFT"
NEXT i

Source: docs/help/keyboard-scan-codes.txt inmmcore. On the computer, typeHELP KEYBOARD CODES.