I'm trying to make a little game for the console, so I need to check which Arrow key is pressed. Can't find anything useful in the internet.
So far I tried this:
printf("%i", getch());
but getch() returns always 27, no matter what arrow I'm pressing.
Any ideas?
arrow keys are internally represented by the characters ESCAPE + "[" + a letter. depending on which arrow key it was: "A" for up, "B" for down, "C" for right, "D" for left.
and ESCAPE is #27. so what's likely happening is you're getting THREEE characters for an arrow press, not just one. you're getting 27 (escape), 91 "[", and then something in the 65-68 range ("A"-"D").