arrow key

just asking, what char numbers are arrow key returning because i only have 1 set of the arrow key number

72 for up
75 for left
77 for right
80 for down

so, there's supposed to be 2 sets, what's the other set ?
just ran some test and found out that each time I pressed arrow key, the num for char -32 appeared
@Flaze07

Not really sure how you're checking for the direction arrow keys, as I just check for ints. Here's a small program I threw together to show you a way to do it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
#include <conio.h>
#include <string>

using std::cout;
using std::endl;
using std::string;


int main()
{
	string direction[4]={"Up","Down","Left","Right"};
	int ch;
	cout << "Pressing the 'Esc' key, ends the program.." << endl;
	do
	{
		ch =  _getch();
		switch(ch)
		{
		case 72:
			cout << "The " << direction[0]<< " arrow was pressed.." << endl;
			break;
		case 75:
			cout << "The " << direction[2]<< " arrow was pressed.." << endl;
			break;
		case 77:
			cout << "The " << direction[3]<< " arrow was pressed.." << endl;
			break;
		case 80:
			cout << "The " << direction[1]<< " arrow was pressed.." << endl;
		}
		
	}while(ch!=27);//ESC key
	cout << endl << endl << "Program finished..." << endl;
    return 0;
}
Topic archived. No new replies allowed.