A lot of code, eh?
The code works by maintaining an array of key states. The '30 times a second' number was pulled out of my hat, simply because it is very unlikely that anybody could press two different keys within 1/30th of a second (even when mashing the keys). In reality, it is "as much as possible". In the preceding paragraphs, I described how the keyboard controller updates the value it returns from the port and then raises the interrupt. What I did not mention (but which was implied) is that that value can be read as many times as you like, and at any time, up until the next keypress when it gets overwritten. It is based on this that I "poll" it, so to say, many times a second.
The main body of the code is very simple in this case: the key state array is declared, and then it enters a loop which repeatedly calls the update function and then shows on the screen the state of every key on the keyboard. The actual work -- that of maintaining the array -- is done by the small [tt]
SUB updateKeyboardArray[/tt]. To use the routine in your code, you need this routine, and one other thing: you need to declare the keyboard state array, as follows:
[tt]
DIM keyDown%(127)
[/tt]
Then, inside your code, your main loop, make sure that [tt]updateKeyboardArray[/tt] is called as often as possible, and at least 30 times a second, and test if keys are down by reading the corresponding elements in the [tt]keyDown%()[/tt] array. A complete list of scan codes is in the help file. The easiest way to get to it is to look up the [tt]ON KEY[/tt] help page.
Good luck
