4 years, 2 months ago.

USBKeyboard Why I can't printf more than 5 brackets?

Very simple code:

  1. include "mbed.h"
  2. include "USBKeyboard.h"

USBKeyboard keyboard;

int main(void) { while (1) { keyboard.printf("[[[[["); wait(2); keyboard.printf("#"); wait(2); } }

I had to use # because when I send the string "]]]]]]]]]" it will actually just print "@@@@@" But it will only print ] five times, even if I send the string "####" it will only print the first five ] and then a bunch of @ even after the code loops. I have to reset the mbed for it to print another five ] and then it goes back to @

I am on a MacBook Pro Retina with TouchBar

Would love any help.

1 Answer

4 years, 2 months ago.

Hello, I solved that on windows with this steps

go to USBDevice/USBHID/USBKeyboard.cpp and define US_KEYBOARD,

then change your PC input language to ENG(United States) US keyboard


I hope this solve your problem, if not, we will have to see the keymap for macbook pro

Thank you for the quick help!

I am using a Japanese computer. Could this library or API output Japanese keys as well? I'm actually just trying to use photoshop shortcuts. Would you happen to know how to send Function keys like F5 and so? In mac you have to press Fn key before.

posted by Julio Ryuuzaki 29 Dec 2016

As I read, Fn key has not a code to send to PC. All the changes are made before send, maybe we could send the code for the actions you want. In other words you will have normal F keys (F1,F2...) and other line of F modified keys. There are already codes for F keys in the keymap, did You tried them?

posted by Gerardo Garza 29 Dec 2016