Are you programming under DOS/WINDOWS? if so,
I think you should make a testing program for keys, like this:
#include<conio.h>
#include<stdio.h>
int main()
{
int c1 = getch();
int c2;
c1 = getch();
if(c1)
{
printf("the ASCII code of the key is {%d}\n", c1);
}else
{
c2 = getch();
printf("the codes of the functional key are {0;%d}\n", c1);
}
return 0;
}
Use the program above to test keys if you don't know the ASCII code of some of them.
So, when you press a character key(for exampla a, b, c, <enter>, <space>, <esc>...), in the keyboard buffer is placed a single character. If you press a functional key, in buffer are paced two characters(<some arrow>, <f1..fXXX>, <ins>...). The first one is 0. If you get 0 it means you should extract the next character.
The next step is waiting for a key to be poressed. The function kbhit() return 0 if no key is pressed. So use
int run = 1;
while(run)
{
while(khhit())
{
c1 = getch();
if(c1)/*process a simple key*/{switch(c1......}
else /*process a functional key*/
{c2 = getch();
switch(c2.....
}
}
/*if you want to exit set run to 0*/
}
Ion Filipski