The keyboard may have caused you some trouble allready. This is how we can read from the keyboard, without using the slow built in functions for wordprocessors. First we read from the keyboard. Unfortunately the OS read from the keyboard all the time, and you can't stop it. Therefor we must empty the keyboard buffer. This QBasic program would fix it :
keycode=inp &H60 'Read from the keyboard port (60 hexadecimal)
junk$=Inkey$ 'Empty the keyboard buffer by reading from it
Every key has its own keycode. The keys even have one keycode when they are pressed, and one when they are released. If you know the press code, you can calculate the release code by adding 128 to the press code. The ESC key, for example, have the code 1 when it's pressed. When you release it, the keyboard will send the signal 129 (1+128) to the port.