-
detecting keypress
hi guys, i've searched the web for this and thhis board but i cant find it. i need to know how to detect a keypress. for example if the right arrow/left arrow/up/down is pressed i need to know. im trying to make a pacman console dealie. this is obviously ssytem dependant so i have either windows with msvc 6.0 (that means no conio.h answers) or linux g++ (but i dont really want X window libraries) thx for responses.
-
Getch() may be what you want. You can just say something like:
char ch=getch();
but I don't know about arrow keys. Maybe someone with more experience could help you out.
-
msvc 6 has conio.h and does have getch() though it's not standard. Well at least my copy of vc6 does. :)
Code:
unsigned key1, key2;
do
{
key1 = getch();
switch(key1)
{
case 0: key2 = getch();
switch(key2)
{
case 72, 75, 77, 80 arrow keys
};
};
}while(key1 != 27);
There is probably a windoze alternative, but I don't know it. :eek:
-
tehehe i had conio and getch all along, i just remembered calling it when i didnt know what i was doing. thx!