using Microsoft.Xna.Framework.Input;
namespace MonoGame.Extended.Input;
///
/// Represents keyboard input.
///
///
/// This is an extended version of the default class
/// which offers internal tracking of both the previous and current state of keyboard input.
///
public static class KeyboardExtended
{
private static KeyboardState _currentKeyboardState;
private static KeyboardState _previousKeyboardState;
///
/// Gets the state of keyboard input.
///
///
/// A value that represents the state of keyboard input.
///
public static KeyboardStateExtended GetState()
{
return new KeyboardStateExtended(_currentKeyboardState, _previousKeyboardState);
}
///
/// Updates the
///
///
/// This internally will overwrite the source data for the previous state with the current state, then get the
/// current state from the keyboard input. This should only be called once per update cycle. Calling it more
/// than once per update cycle can result in the cached previous state being overwritten with invalid data.
///
public static void Update()
{
_previousKeyboardState = _currentKeyboardState;
_currentKeyboardState = Keyboard.GetState();
}
}