USBHIDKeyboard Class

USBHIDKeyboard Class

Description
A class used for creating and managing a USB HID Keyboard.

Syntax
class USBHIDKeyboard

Members

Public Constructors 
USBHIDKeyboard::USBHIDKeyboardConstructs a USBHIDKeyboard object
Public Methods 
USBHIDKeyboard::setReportIDSet HID report ID for the HID Keyboard and HID consumer control
USBHIDKeyboard::consumerReportSend a HID Consumer report
USBHIDKeyboard::keyboardReportSend a HID Keyboard report
USBHIDKeyboard::consumerPressSend a HID Consumer report indicating button pressed
USBHIDKeyboard::consumerReleaseSend a HID Consumer report indicating button released
USBHIDKeyboard::keyPressSend a HID Keyboard report indicating keys pressed
USBHIDKeyboard::keyReleaseSend a HID Keyboard report indicating keys released
USBHIDKeyboard::keyReleaseAllSend a HID Keyboard report indicating no keys pressed
USBHIDKeyboard::keyCharPressSend a HID Keyboard report indicating keys pressed to output an ASCII character
USBHIDKeyboard::keySequenceSend a HID Keyboard report indicating keys pressed to output an ASCII string

USBHIDKeyboard::USBHIDKeyboard

Description
Constructs a USBHIDKeyboard object.

Syntax
USBHIDKeyboard::USBHIDKeyboard();

Parameters
The function requires no input parameter.

Returns
The function returns nothing.

Example Code
Example: USBHIDKeyboard

Notes and Warnings
NA

USBHIDKeyboard::setReportID

Description
Set HID report ID for the HID Keyboard and HID consumer control.

Syntax
void setReportID(uint8_t reportIDKeyboard, uint8_t reportIDConsumer);

Parameters
reportIDKeyboard: The report ID for the HID keyboard device, corresponding to the HID report descriptor.
reportIDConsumer: The report ID for the HID consumer control device, corresponding to the HID report descriptor.

Returns
The function returns nothing.

Example Code
NA

Notes and Warnings
NA

USBHIDKeyboard::consumerReport

Description
Send a HID Consumer report.

Syntax
void consumerReport(uint16_t usage_code);

Parameters
usage_code: HID consumer control usage code for the button pressed.

Returns
The function returns nothing.

Example Code
NA

Notes and Warnings
NA

USBHIDKeyboard::keyboardReport

Description
Send a HID Keyboard report.

Syntax
void keyboardReport();
void keyboardReport(uint8_t modifiers, uint8_t keycode[6]);

Parameters
modifiers: bitmap indicating key modifiers pressed (CTRL, ALT, SHIFT).
keycode: byte array indicating keys pressed.

Returns
The function returns nothing.

Example Code
NA

Notes and Warnings
NA

USBHIDKeyboard::consumerPress

Description
Send a HID Consumer report indicating button pressed.

Syntax
void consumerPress(uint16_t usage_code);

Parameters
usage_code: HID consumer control usage code for the button pressed.

Returns
The function returns nothing.

Example Code
NA

Notes and Warnings
NA

USBHIDKeyboard::consumerRelease

Description
Send a HID Consumer report indicating button released.

Syntax
void consumerRelease();

Parameters
The function requires no input parameter.

Returns
The function returns nothing.

Example Code
NA

Notes and Warnings
NA

USBHIDKeyboard::keyPress

Description
Send a HID Keyboard report indicating keys pressed.

Syntax
void keyPress(uint16_t key);

Parameters
key: HID keycode for key pressed, value ranges from 0x00 to 0xE7.

Returns
The function returns nothing.

Example Code
Example: USBHIDKeyboard

Notes and Warnings
NA

USBHIDKeyboard::keyRelease

Description
Send a HID Keyboard report indicating keys released.

Syntax
void keyRelease(uint16_t key);

Parameters
key: HID keycode for key pressed, value ranges from 0x00 to 0xE7.

Returns
The function returns nothing.

Example Code
NA

Notes and Warnings
NA

USBHIDKeyboard::keyReleaseAll

Description
Send a HID Keyboard report indicating no keys pressed.

Syntax
void keyReleaseAll();

Parameters
The function requires no input parameter.

Returns
The function returns nothing.

Example Code
Example: USBHIDKeyboard

Notes and Warnings
NA

USBHIDKeyboard::keyCharPress

Description
Send a HID Keyboard report indicating keys pressed to output an ASCII character.

Syntax
void keyCharPress(char ch);

Parameters
ch: ASCII character to output.

Returns
The function returns nothing.

Example Code
NA

Notes and Warnings
NA

USBHIDKeyboard::keySequence

Description
Send a HID Keyboard report indicating keys pressed to output an ASCII string.

Syntax
void keySequence (const char* str, uint16_t delayTime);
void keySequence (String str, uint16_t delayTime);

Parameters
str: pointer to character string to output
str: String object containing character string to output
delayTime: time delay between key press and release, in milliseconds. Default value of 5.

Returns
The function returns nothing.

Example Code
Example: USBHIDKeyboard

Notes and Warnings
NA

Please confirm that QQ communication software is installed