Interface IKeyboardManager
Reports the keys that went down, went up or are held, comparing each frame with the one before.
public interface IKeyboardManager
Properties
CurrentState
The keyboard state this frame.
Keyboard.Snapshot CurrentState { get; }
Property Value
KeysDown
The keys that went down since the last frame.
IEnumerable<Key> KeysDown { get; }
Property Value
KeysPressed
The keys held down this frame.
IEnumerable<Key> KeysPressed { get; }
Property Value
KeysRepeated
Keys the OS repeated this frame because they are being held. Empty on the frame a key is first pressed - that one is in KeysDown - and a key held long enough appears here once per repeat, so it can appear more than once in a slow frame.
IEnumerable<Key> KeysRepeated { get; }
Property Value
Remarks
Separate from KeysDown rather than folded into it, because most actions must NOT repeat: held movement is read as a level and paced by the game, and a held Enter must not submit a form thirty times a second. Repeating is opt-in, and the handlers that want it are the text-editing ones.
KeysUp
The keys that went up since the last frame.
IEnumerable<Key> KeysUp { get; }
Property Value
PreviousState
The keyboard state the frame before.
Keyboard.Snapshot PreviousState { get; }
Property Value
Methods
IsKeyPressed(Key)
Whether the key went down this frame.
bool IsKeyPressed(Key key)
Parameters
keyKey
Returns
IsKeyReleased(Key)
Whether the key went up this frame.
bool IsKeyReleased(Key key)
Parameters
keyKey
Returns
Update(IGameTime)
Reads the keyboard for this frame.
void Update(IGameTime gameTime)
Parameters
gameTimeIGameTime