[comp.lang.pascal] Strobing the keyboard

carlson@gateway.mitre.org (Bruce Carlson) (11/09/89)

In article <1261@rodan.acs.syr.edu> wwtaroli@rodan.acs.syr.edu (Bill Taroli) writes:
>I believe this may have been discussed before, but I need this information
>in a hurry.  Is anyone aware of a function in TP that will allow one to 
>strobe the keyboard... or basically check the queue to see if a key is 
>waiting to be read?
>Bill Taroli
>WWTAROLI@RODAN.acs.syr.edu

The function KeyPressed (boolean) determines if a key has been pressed.  It
is nondestructive, so the value is still in the keyboard buffer.
It does not detect the 'shift' keys like Alt, Shift, Numlock, etc.

The function ReadKey reads the value in the keyboard buffer, and you can
then assign this value to one of your variables.  If it is a special 
key (function key, etc.) that generates an extended scan code it will
have two bytes.  The first is #0 and the second is the extended scan code.
The extended scan code keys therefore require two executions of ReadKey.

Bruce Carlson