Class KeyboardDevice
Represents a keyboard device and provides methods to query its status.
Implements
Inherited Members
Namespace: OpenTK.Input
Assembly: OpenTK.dll
Syntax
public sealed class KeyboardDevice : IInputDevice
Properties
Description
Gets a String which describes this instance.
Declaration
public string Description { get; }
Property Value
Type | Description |
---|---|
String |
DeviceID
Gets an IntPtr representing a device dependent ID.
Declaration
public IntPtr DeviceID { get; }
Property Value
Type | Description |
---|---|
IntPtr |
DeviceType
Gets the InputDeviceType for this instance.
Declaration
public InputDeviceType DeviceType { get; }
Property Value
Type | Description |
---|---|
InputDeviceType |
Item[Key]
Gets a value indicating the status of the specified Key.
Declaration
public bool this[Key key] { get; }
Parameters
Type | Name | Description |
---|---|---|
Key | key | The Key to check. |
Property Value
Type | Description |
---|---|
Boolean | True if the Key is pressed, false otherwise. |
Item[UInt32]
Gets a value indicating the status of the specified Key.
Declaration
[CLSCompliant(false)]
public bool this[uint scancode] { get; }
Parameters
Type | Name | Description |
---|---|---|
UInt32 | scancode | The scancode to check. |
Property Value
Type | Description |
---|---|
Boolean | True if the scancode is pressed, false otherwise. |
KeyRepeat
Gets or sets a System.Boolean indicating key repeat status.
Declaration
public bool KeyRepeat { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Remarks
If KeyRepeat is true, multiple KeyDown events will be generated while a key is being held. Otherwise only one KeyDown event will be reported.
The rate of the generated KeyDown events is controlled by the Operating System. Usually, one KeyDown event will be reported, followed by a small (250-1000ms) pause and several more KeyDown events (6-30 events per second).
Set to true to handle text input (where keyboard repeat is desirable), but set to false for game input.
NumberOfFunctionKeys
Gets an integer representing the number of function keys (F-keys) on this KeyboardDevice.
Declaration
public int NumberOfFunctionKeys { get; }
Property Value
Type | Description |
---|---|
Int32 |
NumberOfKeys
Gets an integer representing the number of keys on this KeyboardDevice.
Declaration
public int NumberOfKeys { get; }
Property Value
Type | Description |
---|---|
Int32 |
NumberOfLeds
Gets a value indicating the number of led indicators on this KeyboardDevice.
Declaration
public int NumberOfLeds { get; }
Property Value
Type | Description |
---|---|
Int32 |
Methods
GetHashCode()
Returns the hash code for this KeyboardDevice.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 | A 32-bit signed integer hash code. |
Overrides
GetState()
Retrieves the combined KeyboardState for all keyboard devices. This method is equivalent to GetState().
Declaration
public KeyboardState GetState()
Returns
Type | Description |
---|---|
KeyboardState | An KeyboardState structure containing the combined state for all keyboard devices. |
See Also
GetState(Int32)
Retrieves the KeyboardState for the specified keyboard device. This method is equivalent to GetState(Int32).
Declaration
public KeyboardState GetState(int index)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The index of the keyboard device. |
Returns
Type | Description |
---|---|
KeyboardState | An KeyboardState structure containing the combined state for all keyboard devices. |
See Also
ToString()
Returns a System.String representing this KeyboardDevice.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | A System.String representing this KeyboardDevice. |
Overrides
Events
KeyDown
Occurs when a key is pressed.
Declaration
public event EventHandler<KeyboardKeyEventArgs> KeyDown
Event Type
Type | Description |
---|---|
EventHandler<KeyboardKeyEventArgs> |
KeyUp
Occurs when a key is released.
Declaration
public event EventHandler<KeyboardKeyEventArgs> KeyUp
Event Type
Type | Description |
---|---|
EventHandler<KeyboardKeyEventArgs> |