Sign in to follow this  

WM_CHAR and Windows auto-repeat

This topic is 4394 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hmm... I'm modifying my input system in my game engine so that I can get standard character input (Before it was all Direct Input polling stuff). So, the WM_CHAR message is really nice, except that it's coming in really fast. Basically, when the user just taps the 'k' key, I get something like 12 k's. I know that standard edit controls in Windows don't exhibit this behavior. For example, Notepad behaves the same way as the textbox in my browser - when I hit a character on my keyboard, it gives me the first character, waits about half a second, then starts repeating characters at a constant rate (about 9 a second). Since this seems to be default behavior for windows apps, and I can see it when I open my control panel Windows properties, is there a simple way that I can get my engine to behave the same way? Does windows provide an interface to this, or should I write my own timer-based delay system to ignore the correct CHAR messages? Thanks in advance for any help!

Share this post


Link to post
Share on other sites
It sounds like you are encountering the same problem I had with trying to use the WM_CHAR messages. I never could solve it. I eventually went with using the ToAscii function instead (in the normal keyup/down messages). I'll be interested to hear how this is solved because it really stumped me.

Share this post


Link to post
Share on other sites
I doubt that was WM_CHAR implementation error, it should be your error. WM_CHAR message is processed and sent by Windows in these circumstances:

*User pressed a key once: 3 messages will be sent: WM_KEYDOWN, WM_CHAR and WM_KEYUP

*User pressed a key, held down it for a few seconds then released. a number of these messages will be sent: WM_KEYDOWN, WM_CHAR and WM_KEYDOWN, WM_CHAR and ...
the last message will be WM_KEYUP.

That said, your app shouldn't receive WM_CHAR as if it was polling keys as GetKeyState (). If you're still in doubt, just create a simple textbox then count number of WM_CHAR messages are sent. Number of millisecs Windows has to wait before sending multiple WM_KEYDOWN and WM_CHAR is stored in SM_* (I don't quite remember) by calling GetSystemMetrics () (?) .

Share this post


Link to post
Share on other sites

This topic is 4394 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this