Detecting pressed key

Hi guys,

I trying to detect what user have pressed by GetAsyncKeyState()
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include <window.h>
using namespace std;

int main ()
{

    int Rand;
    srand( time(0));
	Rand=rand()%9+1;
	cout<<Rand;
	
	if (GetAsyncKeyState(........)) // I dont know what to write as parameters for GetAsyncKeyState().
	{
		cout<<"You have pressed the right number.";
	}
	return 0;
}
For the parameters, you need the virtual keys.

Example
1
2
3
4
if (GetAsyncKeyState(VK_SPACE))
{
    std::cout << "Space pressed!";
}


Virtual key list here: http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731%28v=vs.85%29.aspx
Topic archived. No new replies allowed.