Show / Hide Table of Contents

Class KeyboardState

Encapsulates the state of a Keyboard device.

Inheritance
object
KeyboardState
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
Namespace: OpenTK.Windowing.GraphicsLibraryFramework
Assembly: OpenTK.Windowing.GraphicsLibraryFramework.dll
Syntax
public class KeyboardState

Properties

IsAnyKeyDown

Gets a value indicating whether any key is currently down.

Declaration
public bool IsAnyKeyDown { get; }
Property Value
Type Description
bool

true if any key is down; otherwise, false.

this[Keys]

Gets a bool indicating whether the specified Keys is currently down.

Declaration
public bool this[Keys key] { get; }
Parameters
Type Name Description
Keys key

The key to check.

Property Value
Type Description
bool

true if key is down; false otherwise.

Methods

GetSnapshot()

Gets an immutable snapshot of this KeyboardState. This can be used to save the current keyboard state for comparison later on.

Declaration
public KeyboardState GetSnapshot()
Returns
Type Description
KeyboardState

Returns an immutable snapshot of this KeyboardState.

IsKeyDown(Keys)

Gets a bool indicating whether this key is currently down.

Declaration
public bool IsKeyDown(Keys key)
Parameters
Type Name Description
Keys key

The key to check.

Returns
Type Description
bool

true if key is in the down state; otherwise, false.

IsKeyPressed(Keys)

Gets whether the specified key is pressed in the current frame but released in the previous frame.

Declaration
public bool IsKeyPressed(Keys key)
Parameters
Type Name Description
Keys key

The key to check.

Returns
Type Description
bool

True if the key is pressed in this frame, but not the last frame.

Remarks

"Frame" refers to invocations of ( more precisely) here.

IsKeyReleased(Keys)

Gets whether the specified key is released in the current frame but pressed in the previous frame.

Declaration
public bool IsKeyReleased(Keys key)
Parameters
Type Name Description
Keys key

The key to check.

Returns
Type Description
bool

True if the key is released in this frame, but pressed the last frame.

Remarks

"Frame" refers to invocations of ( more precisely) here.

ToString()

Declaration
public override string ToString()
Returns
Type Description
string
Overrides
object.ToString()

WasKeyDown(Keys)

Gets a bool indicating whether this key was down in the previous frame.

Declaration
public bool WasKeyDown(Keys key)
Parameters
Type Name Description
Keys key

The Keys to check.

Returns
Type Description
bool

true if key was in the down state; otherwise, false.

In This Article
Back to top Generated by DocFX