KeyboardState kbstate = Keyboard.GetState();
Keys[] pressed = kbstate.GetPressedKeys();
EnterEscBackspaceAltCtrlWinNumlockHomeIns and possibly more worked fine but when I press any letter, number, or arrows, it won't read it.
I have only ever seen keyboard input handled like so:
KeyboardState kbState = Keyboard.GetState();
if (kbState.IsKeyDown(Keys.A))
{
// 'A' key is down
}
If you wanted key pressed (i.e. the button was just pressed) you would use the following method:
public bool IsNewKeyPress(Keys key)
{
return (kbState.IsKeyDown(key) &&
oldKbState.IsKeyUp(key));
}
// And in the update method...
public void Update(GameTime gameTime)
{
oldKbState = kbState;
kbState = Keyboard.GetState();
if (IsNewKeyPress(Keys.A))
{
// A was *just* pressed
}
// ...
}