win32 test for non-repeat key press

bog standard question, past midnight, clueless.

i'm used to testing for key presses like this and using a bool elsewhere..

1
2
3
4
5
6
7
bool kdaheld;

case WM_KEYDOWN:
		switch(LOWORD(wParam)) {
			case VK_DOWN:	kdaheld = 1;	break;
		}
	    break;

(no idea how to edit tabs in this window..)


which suddenly becomes hell when you want to detect unique key presses and not auto-repeat key presses.

microsoft says, test the 30th bit of lParam to know if it's a repeat state or not, which is probably great advice if i'd ever done anything like that before in my life.

i see people asking for this all over the net and the answer usually looks like this:

 
(lParam & 0xffff)


plugging that into my standard implementation:

1
2
3
int ctrlheld;

case VK_CONTROL:	ctrlheld = (lParam & 0xffff);	break;


this absolutely fails to distinguish between human key presses and auto-repeat, which is a shame, because i was really hoping it would :) it seems to return a value of 1, and the timed event i'm driving does set ctrlheld to 0..

1
2
3
if (ctrlheld > 0) {
do stuff; 
ctrlheld = 0;


so i'm basically floundering here. tia for any insight.. this board moves too quickly for thank you replies!
aah!

it's HIWORD tyvm...

if ((HIWORD(lParam) & KF_REPEAT) < 1) ctrlheld = 1;
Topic archived. No new replies allowed.