Docs / MonoInput

Glossary: KeyboardManager

The members of KeyboardManager, in alphabetical order.

Color legend plain property method

Reads the keyboard at every update, or takes a state the game built, and answers for any key: its state, the modifiers, and every key being touched.

A static class, in the namespace BorrowedTorch.MonoInput.Inputs.Keyboard. It has no events: game code asks it. Until the first Update every key is idle. The keyboard page shows it in context, with code.

Names are colored by what they are: a property or a method; values and fields keep the plain color.

Properties

ActiveKeys →

ActiveInputs<KeyStatus> · Static, read-only. Every key that isn’t idle, in the order they were first pressed: a live view, the same object for the whole run.

IsAltDown →

bool · Static, read-only. Left or right Alt is held: IsKeyDown of either. False from the update Alt is let go.

IsCtrlDown →

bool · Static, read-only. Left or right Control is held: IsKeyDown of either. False from the update Control is let go, so Ctrl+S can’t fire when S goes down just as Control comes up.

IsShiftDown →

bool · Static, read-only. Left or right Shift is held: IsKeyDown of either. False from the update Shift is let go.

Methods

IsKeyActive() →

IsKeyActive(Keys key) · Static. The key is pressed, held or just let go: it is in ActiveKeys.

Parameter Type Description
key Keys The key, as MonoGame names it.

IsKeyDown() →

IsKeyDown(Keys key) · Static. The key is held: Pressed or Down, the update it went down included, as with MonoGame’s KeyboardState.IsKeyDown.

Parameter Type Description
key Keys The key, as MonoGame names it.

IsKeyIdle() →

IsKeyIdle(Keys key) · Static. The key isn’t touched: it isn’t in ActiveKeys.

Parameter Type Description
key Keys The key, as MonoGame names it.

IsKeyPressed() →

IsKeyPressed(Keys key) · Static. The key went down at the last update: true for that update only.

Parameter Type Description
key Keys The key, as MonoGame names it.

IsKeyUp() →

IsKeyUp(Keys key) · Static. The key was let go at the last update: true for that update only. Not the same as MonoGame’s KeyboardState.IsKeyUp, which is true for every key not held.

Parameter Type Description
key Keys The key, as MonoGame names it.

Update() →

Update() · Static. Reads the keyboard with Keyboard.GetState() and moves every key one step. Call it once per frame, before anything checks a key: a second call in the same frame moves the keys again, so a key just pressed reads Down. Doesn’t allocate once its buffer fits the keys held.

Update(KeyboardState keyboardState) · Static. The same, over a state the game built instead of the keyboard: for keys that never reach MonoGame’s Keyboard, such as an editor viewport’s in a window of its own, and for replays and tests. Once per frame too, in place of Update(): the two move the same keys.

Parameter Type Description
keyboardState KeyboardState The keys held now, such as new KeyboardState(heldKeys). Only its keys are read, not its Caps Lock and Num Lock.