***Solved*** HID programming question. Backspace, Enter etc. How to?

Good evening people,

I'm somewhat experimenting with the Keyboard (HID) function of my ProMicro. First I tried to create conditions in which the ProMicro eventually will create characters on my screen. I've tested this successfully using the comport along with the Serial monitor. Serial.println. After understanding that, I'd try to do the real thing with replacing the Serial.print by Keyboard.println

But before doing so, I wondered how I can send commands like [backspace] [enter] etc. Those are not normal Characters. Is it done by ASCII characters?

I found a tutorial or Youtube example some time ago. It was explained usefully. But I cannot seem to find it anymore.

Do you guys have a useful link or otherwise some advice to get me back on track on this?

Regards, Eric

For special keys (like enter, backspace, arrow keys) take a look here: https://www.arduino.cc/reference/en/language/functions/usb/keyboard/keyboardmodifiers/

A tiny sketch for demonstation:

void setup() {
  Keyboard.begin();

  Keyboard.print("Helllo");    // too many Ls...
  delay(700);
  Keyboard.write(KEY_BACKSPACE);
  Keyboard.write(KEY_BACKSPACE);
  delay(700);
  Keyboard.print("o world!");  // now it is: Hello world!
  Keyboard.write(KEY_RETURN);
  Keyboard.print(":-)")
}

void loop() {
}

Find the Keyboard.h file in your Arduino installations. Look for "libraries/Keyboard/src/Keyboard.h". In there you will find a big list of key codes you can send the Keyboard.write() (or for shift keys: Keyboard.press() and later Keyboard.release.)

For example:

#define KEY_UP_ARROW    0xDA
#define KEY_DOWN_ARROW    0xD9
#define KEY_LEFT_ARROW    0xD8
#define KEY_RIGHT_ARROW   0xD7
#define KEY_BACKSPACE   0xB2
#define KEY_TAB       0xB3
#define KEY_RETURN      0xB0
#define KEY_ESC       0xB1
#define KEY_INSERT      0xD1
#define KEY_DELETE      0xD4
#define KEY_PAGE_UP     0xD3
#define KEY_PAGE_DOWN   0xD6
#define KEY_HOME      0xD2
#define KEY_END       0xD5
#define KEY_CAPS_LOCK   0xC1

Ah Great! Thanks Guys!

The page looks familiair. I guess it is the same one I visited some time ago. Lost it... Got it back now.

Tx