Created
January 16, 2015 16:30
-
-
Save sleiner/855afffacf8ef672c8fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <conio.h> | |
char arrowkey_input() { | |
char input_ch = _getch(); | |
// detect arrow keys (idea from http://stackoverflow.com/questions/10463201/getch-and-arrow-codes/11432632#11432632) | |
if (input_ch == -32) { // prefix for arrow keys | |
switch (_getch()) { // the real value | |
case 72: // up | |
return 'u'; | |
case 80: // down | |
return 'd'; | |
case 77: // right | |
return 'r'; | |
case 75: // left | |
return 'l'; | |
} | |
} | |
else | |
return input_ch; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment