Sign in to follow this  
Avenyr

XNA Keyboard Key tracking issue

Recommended Posts

Avenyr    230
I've stumbled upon an odd behavior a few minutes ago.

to make sure it wasn't my code. I created a brand new XNA project and put this code in my update method and a break point inside the If.

[code]
KeyboardState keyboard = Keyboard.GetState();

if (keyboard.IsKeyDown(Keys.A) && keyboard.IsKeyDown(Keys.W) && keyboard.IsKeyDown(Keys.Space))
{

}
[/code]

When I press A + W + Space. the breakpoint is never reached.

Any other combination of keys so far seems to work. Is there any reason why that would be? Would it be Windows / Windows 7 related? perhaps the way my keyboard handles interrupts?

*Edit*

Apparently, My Logitech Wireless Keyboard that I use with my MacBook Proi s unable to process those 3 keys at the same time. I tried using the MacBook Pro's keyboard instead and it works.

What could that be ?

Thanks for the info

Share this post


Link to post
Share on other sites
Flimflam    665
This is a hardware limitation with most keyboards. Many keys share the same circuits with each other, so it doesn't require a dedicated wire for each key. When you press too many keys on the same circuit, the keyboard can no longer distinguish the pressed keys.

It's usually a good idea not to require more than 2 pressed keys at a time, and if you absolutely have to require more, try to require keys that are not close together.

Share this post


Link to post
Share on other sites
Avenyr    230
[quote name='Flimflam' timestamp='1313029415' post='4847460']
This is a hardware limitation with most keyboards. Many keys share the same circuits with each other, so it doesn't require a dedicated wire for each key. When you press too many keys on the same circuit, the keyboard can no longer distinguish the pressed keys.

It's usually a good idea not to require more than 2 pressed keys at a time, and if you absolutely have to require more, try to require keys that are not close together.
[/quote]

Further investigation on that topic does confirm what you said. So in the end, it's not a good idea to rely on multiple key presses.

My issue is that I currently use ASDW for my character controls. I since then switched the control to the keyboard arrows to fix my issue. Luckily I won't have this issue when testing on the xbox.

Thanks for the help!

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