Class GorgonRawKeyboard
Provides events and state for keyboard data returned from Raw Input.
Inherited Members
Namespace: Gorgon.Input
Assembly: Gorgon.Input.dll
Syntax
public class GorgonRawKeyboard : IGorgonKeyboard, IGorgonRawInputDevice, IGorgonRawInputDeviceData<GorgonRawKeyboardData>
Remarks
This allows a user to read keyboard data from Raw Input for all keyboard devices, or an individual device depending on what is passed to the constructor.
Constructors
| Edit this page View SourceGorgonRawKeyboard(IGorgonKeyboardInfo)
Initializes a new instance of the GorgonRawKeyboard class.
Declaration
public GorgonRawKeyboard(IGorgonKeyboardInfo keyboardInfo = null)
Parameters
Type | Name | Description |
---|---|---|
IGorgonKeyboardInfo | keyboardInfo | [Optional] The keyboard information used to determine which keyboard to use. |
Remarks
When the keyboardInfo
is set to null, the system keyboard (that is, all keyboards attached to the computer) will be used. No differentiation between
keyboard devices is made. To specify an individual keyboard, pass an appropriate IGorgonKeyboardInfo obtained from the EnumerateKeyboards() method.
Exceptions
Type | Condition |
---|---|
InvalidCastException | Thrown if the |
Properties
| Edit this page View SourceInfo
Property to return information about this keyboard.
Declaration
public IGorgonKeyboardInfo Info { get; }
Property Value
Type | Description |
---|---|
IGorgonKeyboardInfo |
KeyStates
Property to return the states for each of the Keys.
Declaration
public GorgonKeyStateCollection KeyStates { get; }
Property Value
Type | Description |
---|---|
GorgonKeyStateCollection |
Methods
| Edit this page View SourceKeyToCharacter(Keys, Keys)
Function to convert a keyboard key into a character (if applicable).
Declaration
public string KeyToCharacter(Keys key, Keys modifier)
Parameters
Type | Name | Description |
---|---|---|
Keys | key | The key to convert into a character. |
Keys | modifier | The modifier for that key. |
Returns
Type | Description |
---|---|
string | The character representation for the key. If no representation is available, an empty string is returned. |
Remarks
Use this to retrieve the character associated with a keyboard key. For example, if A is pressed, then 'a' will be returned. A modifier
can be
passed with the ShiftKey to return 'A'.
This method also supports the AltGr key which is represented by a combination of the ControlKey | Menu keys.
This method only returns characters for the currently active keyboard layout (i.e. the system keyboard layout). If this keyboard interface represents another keyboard attached to the computer then it will default to using the system keyboard to retrieve the character.
This method is not thread safe. Invalid data will be returned if multiple thread access this method.
Events
| Edit this page View SourceKeyDown
Event fired when a key is pressed on the keyboard.
Declaration
public event EventHandler<GorgonKeyboardEventArgs> KeyDown
Event Type
Type | Description |
---|---|
EventHandler<GorgonKeyboardEventArgs> |
KeyUp
Event fired when a key is released on the keyboard.
Declaration
public event EventHandler<GorgonKeyboardEventArgs> KeyUp
Event Type
Type | Description |
---|---|
EventHandler<GorgonKeyboardEventArgs> |