Class KeyboardState
Encapsulates the state of a Keyboard device.
Inherited Members
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 |
|
this[Keys]
Declaration
public bool this[Keys key] { get; }
Parameters
| Type | Name | Description |
|---|---|---|
| Keys | key | The key to check. |
Property Value
| Type | Description |
|---|---|
| bool |
|
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 |
|
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
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
ToString()
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string |
Overrides
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 |
|