# KEYDOWN()

Compatible with:
DOS Maximite CMM MM150 MM170 MM+ MMX Picromite ArmiteL4 Armite F4 ArmiteH7 Picomite CMM2

Syntax:
KEYDOWN(n)
KEYDOWN

Description:

On the CMM2
KEYDOWN(n)
Return the decimal ASCII value of the USB keyboard key that is currently held down or zero if no key is down.
The decimal values for the function and arrow keys are listed with the full ASCII table.
This function will report multiple simultaneous key presses and the parameter 'n' is the number of the keypress to report.

KEYDOWN(0) will return the number of keys being pressed
For example, if "c", "g" and "p" are pressed simultaneously KEYDOWN(0) will return 3, KEYDOWN(1) will return 99, KEYDOWN(2) will return 103, etc.
The keys do not need to be pressed simultaneously and will report in the order pressed. Taking a finger off a key will promote the next key pressed to #1.
The first key ('n' = 1) is entered in they keyboard buffer (accessible using INKEY$) while keys 2 to 6 can only be accessed via this function.
Using this function will clear the console input buffer.

KEYDOWN(7) will give any modifier keys that are pressed.
These keys do not add to the count in keydown(0) The return value is a bitmask as follows: lalt =1, lctrl = 2, lgui = 4, lshift = 8, ralt = 16, rctrl = 32, rgui = 64, rshift = 128

KEYDOWN(8) will give the current status of the lock keys. These keys do not add to the count in keydown(0)
The return value is a bitmask as follows: caps_lock = 1, num_lock = 2, scroll_lock = 4
Note that some keyboards will limit the number of active keys that they can report.

CLS
DO
IF KEYDOWN(0) <> 0 THEN
PRINT @(0,0),STR$(KEYDOWN(0),4), STR$(KEYDOWN(1),4),STR$(KEYDOWN(2),4),STR$(KEYDOWN(3),4);
print STR$(KEYDOWN(4),4),STR$(KEYDOWN(5),4),STR$(KEYDOWN(6)),BIN$(KEYDOWN(7),8)
ENDIF
PAUSE 200
LOOP

On the CMM1 and Mono Maximite
KEYDOWN
Return the decimal ASCII value of the PS2 keyboard key that is currently held down or zero if no key is down.
The decimal values for the function and arrow keys are listed in Appendix F.
Note that this function will only work with the attached PS2 keyboard and that using this function will also clear any characters stored in the keyboard input buffer.

Last edited: 15 December, 2020