Skip to main content

Keyboard Class

NuGet: GHIElectronics.TinyCLR.Devices.UsbHost
Assembly: GHIElectronics.TinyCLR.Devices.UsbHost
Namespace: GHIElectronics.TinyCLR.Devices.UsbHost

Allows a usb device to be used as a keyboard.

public class Keyboard : BaseDevice

Constructors​

Keyboard(uint id, byte interfaceIndex)​

public Keyboard(uint id, byte interfaceIndex) : base(id, interfaceIndex, DeviceType.Keyboard)

Creates a new keyboard.

ParameterTypeDescription
iduintThe device id.
interfaceIndexbyteThe device interface index.

Methods​

IsKeyPressed(Key key)​

public KeyState IsKeyPressed(Key key)

Gets the current state of a key.

ParameterTypeDescription
keyKeyThe key to query.

Returns KeyState — The state of the key.

Dispose(bool disposing)​

protected override void Dispose(bool disposing)

Disposes the keyboard.

ParameterTypeDescription
disposingboolWhether or not this is called from Dispose.

CheckEvents(object sender)​

protected override void CheckEvents(object sender)

Repeatedly called with a period defined by WorkerInterval. Used to poll the device for data and raise any desired events.

ParameterTypeDescription
senderobjectAlways null.

Events​

KeyUp​

public event KeyboardEventHandler KeyUp

Fired when a key is released.

KeyDown​

public event KeyboardEventHandler KeyDown

Fired when a key is pressed.

CharUp​

public event KeyboardEventHandler CharUp

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

CharDown​

public event KeyboardEventHandler CharDown

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