I’m writing a programm that’s using getch() to scan for arrow keys. My code so far is:
switch(getch()) {
case 65: // key up
break;
case 66: // key down
break;
case 67: // key right
break;
case 68: // key left
break;
}
Problem is that when I press 'A', 'B', 'C' or 'D' the code will also executed, because 65 is the decimal code for 'A', etc…
Is there a way to check for an arrow key without call others?
Thanks!
By pressing one arrow key
getchwill push three values into the buffer:'\033''[''A','B','C'or'D'So the code will be something like this: