Skip to main content

Keyboard Class

Package: GHIElectronics.Endpoint.Devices.UsbHost
Namespace: GHIElectronics.Endpoint.Devices.UsbHost

Allows a usb device to be used as a keyboard.

class Keyboard(BaseDevice): ...

Remarks​

The CharUp and CharDown events are only fired when a given key press has a corresponding ASCII key code (a US keyboard; Ctrl+A to Ctrl+Z give 1 to 26). A key held down gives one KeyDown. The events come on the keyboard's own thread.

Nested Types​

TypeKindSummary
Keyboard.KeyboardEventArgsClassEvent arguments for the keyboard events.
Keyboard.KeyboardEventHandlerDelegateThe handler for used for keyboard callbacks.

Constructors​

Keyboard(string deviceName)​

def __init__(self, deviceName: str):

Opens the keyboard that UsbHostController reported ("/dev/input/event1").

Methods​

IsKeyPressed(Key key)​

def IsKeyPressed(self, key: Key) -> KeyState:

Gets the current state of a key.

ParameterTypeDescription
keyKeyThe key to query.

Returns KeyState: The state of the key.

Events​

CharDown​

CharDown # += / -= handler

Fired when a key is pressed and it can be converted to ASCII.

CharUp​

CharUp # += / -= handler

Fired when a key is released and it can be converted to ASCII.

KeyDown​

KeyDown # += / -= handler

Fired when a key is pressed.

KeyUp​

KeyUp # += / -= handler

Fired when a key is released.