Inconsistent events in the InputManager?

Feb 19, 2012 at 6:01 PM

.KeyPressed will fire every single time the update event is called and a key is down, while .KeyReleased only happens once after releasing a key.

 

It's easy enough to implement the sentinal to make a single pop KeyPressed event, but it just hurts my OCD :D

 

Thanks for the awesome framework!

Coordinator
Feb 21, 2012 at 9:34 AM

That's intentional - but the event should be happened with your keyboard repeat rate, not once per Update() call. This is analogous to how the KeyDown event in WinForms works and to how Windows sends its WM_KEYDOWN messages.

Keystrokes are also buffered, so if the user holds down some key for a second and your game loop pauses during that (eg. calling some of the dialog-enabled guide methods), your game would get all the buffered events with the next Update() call.

Please double-check whether it's just doing that, or whether you're really getting a KeyPressed each and every update. If the latter is the case, that would be a bug -- but I can't imagine that happening since the library doesn't compare the state of keyboard or something like that in Update(), it only forwards the KeyPressed notifications that have been recorded from window messages since the last call.