Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change repeat key threshold c++

Tags:

c++

native

winapi

I'm building a c++ tetris game (not c++ .Net). I feel my controls are weird. I want to make it so that when user presses one of the arrow keys, about 10ms of holding it down will start the repeat function windows has. It is set to about 500ms by default, and it is too laggy for my game. How can I set the speed at which it changes from the keydown to the repeat keydown? Not how many times / sec it repeats.

Thanks

*what I want to do is change the repeat delay to short

In control panel in keyboard settings there is repeat rate, how do i set this?

like image 677
jmasterx Avatar asked Jan 28 '26 14:01

jmasterx


1 Answers

Typically what you would do for this is instead of reacting to the WM_CHAR message that is subject to the normal key repeat settings, you would look for WM_KEYDOWN and WM_KEYUP, and take action based on a timer that you've got running. If you set the timer to fire every 50 ms for example, then you can repeat every 50 ms and still take the first action immediately when you get the WM_KEYDOWN message.

like image 166
Greg Hewgill Avatar answered Jan 31 '26 04:01

Greg Hewgill



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!