it's a console application if you guys wonder, i don't really have a problem with just using WASD instead but i wouldn't mind being able to use the arrow keys.
char _input = 0;
char _up = 'Z';
char _down = 'S';
char _left = 'Q';
char _right = 'D';
do
{
_input = _getch();
switch (_input)
{
case 'Z':
case 'z':
_input = _up;
break;
case 'Q':
case 'q':
_input = _left;
break;
case 'S':
case 's':
_input = _down;
break;
case 'D':
case 'd':
_input = _right;
break;
}
} while (_input == 0);
Here is the original answer :
Check for the following values:
KEY_UP = 72
KEY_DOWN = 80
KEY_LEFT = 75
KEY_RIGHT = 77
like
#define KEY_UP 72
...
...
do
{
_value= _getch();
switch(_value) {
case KEY_UP: {...}
...
}
} while (...);
...
and the docs defining all the keyboard values.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.