Embed: (wiki syntax)

« Back to documentation index

USBKeyboard Class Reference

USBKeyboard Class Reference

USB device: a keyboard. More...

#include <USBKeyboard.h>

Inherits GenericKeyboard, and USBHID.

Public Member Functions

 USBKeyboard ()
 Constructor for a keyboard.
bool keyCode (uint8_t modifier, uint8_t key)
 Send all kinds of characters (ctrl + key, ...).
virtual int _putc (int c)
 Send a character.
bool mediaControl (MEDIA_KEY key)
 Control media keys.

Detailed Description

USB device: a keyboard.

Warning: you can only instantiate one instance of a USB device: USBMouse, USBKeyboard, USBAbsMouse, USBMouseKeyboard, or USBAbsMouseKeyboard.

Example:

 #include "mbed.h"
 #include "USBKeyboard.h"

 USBKeyboard key;
 
 int main(void)
 {
   while (1)
   {
       key.puts("Hello World\r\n");
       wait(1);
   }
 }

Definition at line 34 of file USBKeyboard.h.


Constructor & Destructor Documentation

USBKeyboard (  )

Constructor for a keyboard.

Definition at line 40 of file USBKeyboard.h.


Member Function Documentation

int _putc ( int  c ) [virtual, inherited]

Send a character.

Parameters:
ccharacter to be sent
Returns:
true if there is no error, false otherwise

Definition at line 10 of file GenericKeyboard.c.

bool keyCode ( uint8_t  modifier,
uint8_t  key 
) [inherited]

Send all kinds of characters (ctrl + key, ...).

 //To send CTRL + s (save)
  keyboard.keyCode(CTRL, 's');
Parameters:
modifierbit 0: CTRL, bit 1: SHIFT, bit 2: ALT
keycharacter to send
Returns:
true if there is no error, false otherwise

Definition at line 14 of file GenericKeyboard.c.

bool mediaControl ( MEDIA_KEY  key ) [inherited]

Control media keys.

Parameters:
keymedia key pressed (KEY_NEXT_TRACK, KEY_PREVIOUS_TRACK, KEY_STOP, KEY_PLAY_PAUSE, KEY_MUTE, KEY_VOLUME_UP, KEY_VOLUME_DOWN)
Returns:
true if there is no error, false otherwise

Definition at line 47 of file GenericKeyboard.c.