Table of Contents

Interface IKeyboardManager

Namespace
BSGameLib.Game.Input
Assembly
BSGameLib.Game.dll

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

Keyboard.Snapshot

KeysDown

The keys that went down since the last frame.

IEnumerable<Key> KeysDown { get; }

Property Value

IEnumerable<Key>

KeysPressed

The keys held down this frame.

IEnumerable<Key> KeysPressed { get; }

Property Value

IEnumerable<Key>

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

IEnumerable<Key>

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

IEnumerable<Key>

PreviousState

The keyboard state the frame before.

Keyboard.Snapshot PreviousState { get; }

Property Value

Keyboard.Snapshot

Methods

IsKeyPressed(Key)

Whether the key went down this frame.

bool IsKeyPressed(Key key)

Parameters

key Key

Returns

bool

IsKeyReleased(Key)

Whether the key went up this frame.

bool IsKeyReleased(Key key)

Parameters

key Key

Returns

bool

Update(IGameTime)

Reads the keyboard for this frame.

void Update(IGameTime gameTime)

Parameters

gameTime IGameTime