David pretty much summed it up entirely. However, if you are interested I attached at the end a condensed version of what I use. It's just a game component you can add to the game with Components.Add() then call to check if buttons were just pressed, released, or are currently down. You can just throw it directly in your project (you might want to change the namespace though). If you need help/an explanation let me know. Happy coding.
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using System.Reflection;
namespace XNAGenericsLibrary
{
public class InputHandler : Microsoft.Xna.Framework.GameComponent
{
#region Field Region
static KeyboardState keyboardState;
static KeyboardState lastKeyboardState;
static GamePadState[] gamePadState;
static GamePadState[] lastGamePadState;
#endregion
#region Property Region
public static KeyboardState KeyboardState
{
get { return keyboardState; }
}
public static KeyboardState LastKeyboardState
{
get { return lastKeyboardState; }
}
public static GamePadState[] GamePadStates
{
get { return gamePadState; }
}
public static GamePadState[] LastGamePadStates
{
get { return lastGamePadState; }
}
#endregion
#region Constructor Region
public InputHandler(Game game)
: base(game)
{
keyboardState = Keyboard.GetState();
gamePadState = new GamePadState[EnumMethods.GetValuesArray<PlayerIndex>().Length];
foreach (PlayerIndex index in EnumMethods.GetValuesArray<PlayerIndex>())
gamePadState[(int)index] = GamePad.GetState(index);
}
#endregion
#region XNA methods
public override void Update(GameTime gameTime)
{
lastKeyboardState = keyboardState;
keyboardState = Keyboard.GetState();
lastGamePadState = (GamePadState[])gamePadState.Clone();
foreach (PlayerIndex index in EnumMethods.GetValuesArray<PlayerIndex>())
gamePadState[(int)index] = GamePad.GetState(index);
base.Update(gameTime);
}
#endregion
#region Keyboard Region
public static bool KeyboardPressed(Keys key)
{
return (keyboardState.IsKeyDown(key) && lastKeyboardState.IsKeyUp(key));
}
public static bool KeyboardReleased(Keys key)
{
return (keyboardState.IsKeyUp(key) && lastKeyboardState.IsKeyDown(key));
}
public static bool KeyboardDown(Keys key)
{
return keyboardState.IsKeyDown(key);
}
#endregion
#region GamePad Region
public static bool GamePadButtonPressed(Buttons button, PlayerIndex index)
{
return (gamePadState[(int)index].IsButtonDown(button) && lastGamePadState[(int)index].IsButtonUp(button));
}
public static bool GamePadButtonReleased(Buttons button, PlayerIndex index)
{
return (gamePadState[(int)index].IsButtonUp(button) && lastGamePadState[(int)index].IsButtonDown(button));
}
public static bool GamePadButtonDown(Buttons button, PlayerIndex index)
{
return gamePadState[(int)index].IsButtonDown(button);
}
#endregion
}
class EnumMethods
{
public static T[] GetValuesArray<T>()
{
return (typeof(T).GetFields(BindingFlags.Static | BindingFlags.Public).Select(x => (T)x.GetValue(null))).ToArray<T>();
}
}
}
EDIT- By the way, this works with the XBox 360 which uses the Compact Framework. If targeting the PC you can replace calls to EnumMethods.GetValuesArray() with Enum.GetValues(), which would probably be more efficient.