KeyboardState Structure (Microsoft.Xna.Framework.Input)

Holds the state of keystrokes by a keyboard.

Namespace: Microsoft.Xna.Framework.Input
Assembly: MonoGame.Framework (MonoGame.Framework.dll 3.8.0.1082)
  • C#
  • VB
  • F#
[DefaultMemberAttribute("Item")]
[StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = -1, Size = -1)]
public struct KeyboardState

Syntax for VB is not yet implemented.

Syntax for F# is not yet implemented.

The KeyboardState type exposes the following members.

  Platforms Name Description
KeyboardState(Keys[], bool, bool) Initializes a new instance of the KeyboardState class. 
KeyboardState(Keys[]) Initializes a new instance of the KeyboardState class. 
Top
  Platforms Name Description
CapsLock Gets the current state of the Caps Lock key. 
Item Returns the state of a specified key. 
NumLock Gets the current state of the Num Lock key. 
Top
  Platforms Name Description
Equals Compares whether current instance is equal to specified object. (Overrides ValueType.Equals().)
GetHashCode Gets the hash code for KeyboardState instance. (Overrides ValueType.GetHashCode().)
GetPressedKeyCount Returns the number of pressed keys in this KeyboardState
GetPressedKeys() Returns an array of values holding keys that are currently being pressed. 
GetPressedKeys(Keys[]) Fills an array of values holding keys that are currently being pressed. 
IsKeyDown Gets whether given key is currently being pressed. 
IsKeyUp Gets whether given key is currently being not pressed. 
Top
  Platforms Name Description
Equality Compares whether two KeyboardState instances are equal. 
Inequality Compares whether two KeyboardState instances are not equal. 
Top
Supported in:

    
 Windows DirectX Desktop
    
 Linux Desktop
    
 Windows OpenGL Desktop
    
 Web