Sign in to follow this  
Khaos Dragon

..net keydown event registering multiple times

Recommended Posts

In my c# app, I need a callback to respond only when a key is first initially pressed. However for some reason, the "KeyDown" event seems to generated constantly while the key is held down and in this respect is acting just like the keypress event. All my google research seems to have found no one with this problem with their keydown event working as advertised in the sdk. I am wondering if there might be a reason for this? If not, then is there a way to disable buffered keyboard input in my application?

Share this post


Link to post
Share on other sites
maybe put a variable which resets onkeyup and then in onkeydown put an if() statement testing the value of this variable?

Share this post


Link to post
Share on other sites
Eh? IIRC, the keydown event is 'as advertised' supposed to trigger multiple times.

*doublechecks Petzold* Yes, that's expected behavior.

Share this post


Link to post
Share on other sites
As the others have said this is actually the correct behavior for the key down event in both .NET and Win32. To find out more specifics do a search on MSDN for OnKeyDown, OnKeyPress or KeyPressEventArgs.

Share this post


Link to post
Share on other sites
In Win32 you would check LPARAM for the keydown message to see if the key was pressed more than onced. But I'm not sure if this also pertains to C# Windows Programming. Hope it helps though.


xeddiex

Share this post


Link to post
Share on other sites

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