Keyboard.h how to output #?

I'm building a small macropad using a micro.
I've got things like copy and paste working just fine, also printing simple words etc...

I want to use one key to basically print out a hashtag #text. My issue is that when I press the key, using

keyboard.print("#text");

it it prints § instead of #.
Even when I use the ASCII code

Keyboard.write(35);
Keyboard.print(text);

Still §.

Why? How can the ASCII be interpreted differently?
Any ideas on how I can print a #?

It’s not ascii related but keyboard mapping related. I assume your pc is not using QWERTY / American layout? You need to find which symbol is at the same place as your # on a US keyboard and send that character

1 Like

It worked! It's the backslash (\). That did come with its own problem though. It broke the syntax (I'm guessing, since it changed the color of the quoted text) and only returned text instead of #text.
I worked around that by going the ASCII rout for the backslash

Keyboard.write(92);
delay(1);
Keyboard.print("text");

Thank you though for the pointers!

to send a backslash you need to send two of them... look at escape sequence in c++
so would be :Keyboard.write('\\');

but good to know you fixed it! have fun

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.