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

ON KEY  interrupt_routine
ON KEY [ASCIIcode,] interrupt_routine

Setup an interrupt which will call 'target' user defined subroutine whenever there is one or more characters waiting in the serial console input buffer. 
Note that all characters waiting in the input buffer should be read in the interrupt subroutine otherwise another interrupt will be automatically generated as soon as the program returns from the interrupt. 
To disable this interrupt, use numeric zero for the target, ie: ON KEY 0

On the CMM2
ON KEY [ASCIIcode,] interrupt_routine
There is an optional first parameter for ON KEY. This allows you to associate an interrupt routine with a specific key press. 
This operates at a low level for both the USB keyboard and a serial console and if activated the key does not get put into the input buffer but merely triggers the interrupt. 
On the USB keyboard the "print screen" key generates ASCII code &H94 and the "pause/break" key generates &H95 
This would allow a program to easily implement a save-screen routine by associating the "print screen" key with an interrupt and putting a "save image" command into the interrupt routine. 
Obviously this is bad practice (long duration command in interrupt routine) and it would be better to just set a flag and do the "save image" in the main program once it sees the flag. 

The new command uses a separate interrupt from the simple ON KEY command so can be used at the same time if required.


Last edited: 30 September, 2020