how i check for arrow keys pressing using standard io functions? (nothing of allegro)
Printable View
how i check for arrow keys pressing using standard io functions? (nothing of allegro)
I made this simple program to see what code correspond to every key you press on your keyboard using Turbo C++ 3.0
void main (void)
{
char c;
printf ("Press a key ");
c = getch ();
if (c == 0) c = getch ();
printf ("\n the code for the key you pressed is %.0f ", (float)c);
fflush (stdin);
}
Now you know the code, so you can use
if (c == 72) then ......
Sorry but i don't know how to tab :(
just put thing in between code blocks. You cant tab though so just mash space 4 times:
:DCode:int main ()
{
char c;
printf ("Press a key ");
c = getch ();
if (c == 0) c = getch ();
printf ("\n the code for the key you pressed is %.0f ", (float)c);
fflush (stdin);
}