[comp.sys.ibm.pc] Reading extended keys

KQS@psuvm.psu.edu (Kevin Sullivan) (06/15/91)

I took this out of the C language groups, since it is not appropriate there...

The code returned when a key is pressed has to be in the range 0-255.
However, there are more than 255 different key-combinations.  To get
around this, IBM uses a special code to flag special keys.  Whenever
a special key (F1, for example) is pressed, two numbers are put into
the keyboard buffer.  The first is a 0, the second is a number representing
the key that was pressed.

Therefore, if getchar() returns a '\0', you know that:
    1) A special key has been pressed and
    2) You must call getchar() again to find out which special key was
       pressed.

I don't have a list of what the various key codes are with me, but it is
trivial to write a program to show the codes and write them down.

     Kevin Sullivan                       BITNET: KQS@PSUVM
     Student Consultant - CAC           INTERNET: kqs@vm.psu.edu
     Penn State University
                                        Old programmers don't die...they
I don't speak for Penn State...         just branch to a new address.
Penn State doesn't speak for me.