Class KeyboardDevice
Represents a keyboard device and provides methods to query its status.
Inheritance
Implements
Inherited Members
Namespace: OpenTK.Input
Assembly: cs.temp.dll.dll
Syntax
public sealed class KeyboardDevice : IInputDevice
Properties
Description
Gets a System.String which describes this instance.
Declaration
public string Description { get; }
Property Value
Type | Description |
---|---|
System.String |
DeviceID
Gets an IntPtr representing a device dependent ID.
Declaration
public IntPtr DeviceID { get; }
Property Value
Type | Description |
---|---|
System.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 |
---|---|
System.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 |
---|---|---|
System.UInt32 | scancode | The scancode to check. |
Property Value
Type | Description |
---|---|
System.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 |
---|---|
System.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 |
---|---|
System.Int32 |
NumberOfKeys
Gets an integer representing the number of keys on this KeyboardDevice.
Declaration
public int NumberOfKeys { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
NumberOfLeds
Gets a value indicating the number of led indicators on this KeyboardDevice.
Declaration
public int NumberOfLeds { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
GetHashCode()
Returns the hash code for this KeyboardDevice.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.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 |
---|---|---|
System.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 |
---|---|
System.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 |
---|---|
System.EventHandler<KeyboardKeyEventArgs> |
KeyUp
Occurs when a key is released.
Declaration
public event EventHandler<KeyboardKeyEventArgs> KeyUp
Event Type
Type | Description |
---|---|
System.EventHandler<KeyboardKeyEventArgs> |