Detect numeric keys with few statements

I have to detect key input from the keypad (1-9) as well as whether CTRL/SHIFT/ALT was held down at the same time. I'm currently using multiple GetAsyncKeyState functions right now in if statements. I'll experiment using a switch statement for this purpose if there is no other way to achieve this.
Basically what I'm looking for is a tidier way of achieving this:
1
2
3
4
5
6
7
8
9
10
11
if ((GetAsyncKeyState(SHIFT) && KEY_PRESSEDFORCE) && (GetAsyncKeyState(CTRL) && KEY_PRESSEDFORCE) && (GetAsyncKeyState(ONE) && KEY_PRESSED))
{
        multiClipboard.getCB(0);
	Sleep(500);
}
if ((GetAsyncKeyState(SHIFT) && KEY_PRESSEDFORCE) && (GetAsyncKeyState(CTRL) && KEY_PRESSEDFORCE) && (GetAsyncKeyState(TWO) && KEY_PRESSED))
{
	multiClipboard.getCB(1);
	Sleep(500);
}
.... (There are more of these, up to NINE, but this gets the point across)


(ONE-NINE, CTRL, SHIFT, KEY_PRESSED etc are all enumerators containing the code for the keypads.)
Last edited on
¿has got `GetAsyncKeyState()' any secondary effects?
1
2
3
if (GetAsyncKeyState(SHIFT) and GetAsyncKeyState(CTRL)){
   //check for the numbers
}
That's the solution I ended up with, seems it's the tidiest way to accomplish this
Topic archived. No new replies allowed.