Skip to content

KeyboardStateManager.cs

Charles Humphrey edited this page Nov 19, 2017 · 3 revisions

RandomchaosMGBase.InputManagers.KeyboardStateManager

This class derives from GameComponent and handles keyboard input.

Public Fields

KeyboardState State

This is the current state of the keyboard, it is set on each Update(GameTime gameTime) call.

KeyboardState LastState

This is the last state of the keyboard,it is set on each PreUpdate(GameTime gameTime) call.

Public Properties

bool NumLock

Is true if NumLock is active.

bool CapsLock

Is true if CapsLock is active

bool ShiftIsDown

Is true if either Shit key is down.

bool CtrlIsDown

Is true if either Ctrl key is down.

Public Methods

KeyboardStateManager(Game game)

This is the class constructor, it put's this instance of the class into the Game.Components list as well as registering it's self as a Game.Service.

Keys[] KeysPressed()

This returns an array of all the current keys being pressed.

Keys[] KeysPressedThisFrame()

This returns an array of all the keys pressed in this frame and not in the last frame.

bool KeyDown(Keys key)

Is true if the given key is down

bool KeyPress(Keys key)

Is true if the given key was down last frame but not now.

void Update(GameTime gameTime)

Sets the State to the current keyboard sate.

void PreUpdate(GameTime gameTime)

Sets the LastState to State, this should be called at the top of the Game.Update method.

Clone this wiki locally