Checking for alternate keys with XNA IsKeyDown

Posted by jocull on Game Development See other posts from Game Development or by jocull
Published on 2012-09-24T22:08:53Z Indexed on 2012/09/25 3:50 UTC
Read the original article Hit count: 298

Filed under:
|
|

I'm working on picking up XNA and this was a confusing point for me.

KeyboardState keyState = Keyboard.GetState();
if (keyState.IsKeyDown(Keys.Left) || keyState.IsKeyDown(Keys.A))
{
    //Do stuff...
}

The book I'm using (Learning XNA 4.0, O'Rielly) says that this method accepts a bitwise OR series of keys, which I think should look like this...

KeyboardState keyState = Keyboard.GetState();
if (keyState.IsKeyDown(Keys.Left | Keys.A))
{
    //Do stuff...
}

But I can't get it work. I also tried using !IsKeyUp(... | ...) as it said that all keys had to be down for it to be true, but had no luck with that either. Ideas? Thanks.

© Game Development or respective owner

Related posts about XNA

Related posts about c#