Class KeyboardManager
Manages the physical keyboard.
Inheritance
Inherited Members
Namespace: Cosmos.System
Assembly: Cosmos.System2.dll
Syntax
public static class KeyboardManager
Properties
| Improve this Doc View SourceAltPressed
Whether the Alt key is currently pressed.
Declaration
public static bool AltPressed { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
CapsLock
The caps-lock state.
Declaration
public static bool CapsLock { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
ControlPressed
Whether the Control (Ctrl) key is currently pressed.
Declaration
public static bool ControlPressed { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
KeyAvailable
Whether a keyboard input is pending to be processed; i.e, whether the queued key-press buffer is not empty.
Declaration
public static bool KeyAvailable { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
NumLock
The num-lock state.
Declaration
public static bool NumLock { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
ScrollLock
The scroll-lock state.
Declaration
public static bool ScrollLock { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
ShiftPressed
Whether the Shift key is currently pressed.
Declaration
public static bool ShiftPressed { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
| Improve this Doc View SourceGetKey(Byte, out KeyEvent)
Attempts to convert the given physical key scan-code to a KeyEvent instance.
Declaration
public static bool GetKey(byte scanCode, out KeyEvent keyInfo)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | scanCode | The scan-code of the physical key. |
KeyEvent | keyInfo | The resulting KeyEvent. |
Returns
Type | Description |
---|---|
System.Boolean | true if the operation succeded and |
GetKeyLayout()
Gets the currently used keyboard layout.
Declaration
public static ScanMapBase GetKeyLayout()
Returns
Type | Description |
---|---|
ScanMapBase |
ReadKey()
Reads the next key from the pending key-press keyboard buffer, and removes it from said buffer.
Declaration
public static KeyEvent ReadKey()
Returns
Type | Description |
---|---|
KeyEvent | The pending key-press. |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Thrown when the queue is empty. |
SetKeyLayout(ScanMapBase)
Sets the currently used keyboard layout.
Declaration
public static void SetKeyLayout(ScanMapBase scanMap)
Parameters
Type | Name | Description |
---|---|---|
ScanMapBase | scanMap | The keyboard scan map to use. |
TryReadKey(out KeyEvent)
If available, reads the next key from the pending key-press keyboard buffer, and removes it from said buffer.
Declaration
public static bool TryReadKey(out KeyEvent key)
Parameters
Type | Name | Description |
---|---|---|
KeyEvent | key | The pending key-press. |
Returns
Type | Description |
---|---|
System.Boolean | true if a key-press was pending and has been dequeued to |