So I want to use arduino Leonardo as a macro keyboard, however every time i try to print bslash like this:
Keyboard.print(\\)
I get either $ or £. I did some research and it seems that my swiss layout keyboard has a dedicated key for this next to Y ( Z on US Layout) that isn't mapped in the Keyboard library, and I couldn't find any other way to type \ on swiss layout.
So how can I print bslash using Keyboard.h? Is there any way to print characters independent of the current Windows keyboard layout?
btw. Sorry for grammar and terrible formatting, im on the phone right now and english isn't my first language
The problem is that a USB keyboard doesn't send ASCII. It sends a code indicating a key on the keyboard. By default, the Keyboard library translates ASCII characters to the key code they have on the US-English keyboard and then the OS translates the keycode back to a character. If the currently selected keyboard layout is not US-English the OS may translate to the wrong character.
One workaround is the KeyboardUTF8 library I wrote last year. It takes any string of UTF8 characters up to 0xFFFF (which includes backslash) and sends the right keystrokes for the specified keyboard layout.