4

I've got an Adafruit Trinket microcontroller set up using this USB keyboard tutorial, and it works great.

I'd like to set up my project to type a shruggie ( ¯\_(ツ)_/¯ ) when I press a hardware button.

My naive solution was:

TrinketKeyboard.print("¯\_(ツ)_/¯");

But that only printed the underscores, parentheses and slashes, not the "hands" or the "face."

Is there a standard keyboard input method I could use so this device, when plugged into any Mac, will type out a string that includes Unicode (specifically Katakana) characters?

An ideal solution does not require configuring the machine before plugging this widget in, and doesn't require changing state on the machine -- although I'll take what I can get! :) (e.g., configuring Japanese keyboard support and toggling input source -- all of which is done blind since the computer can't give feedback to a lowly keyboard -- is un-ideal.)

1
  • 1
    Doesn't seem to be possible without the Unicode hex input setting.
    – Gerben
    Aug 29, 2016 at 18:22

2 Answers 2

2

You could hack it.

  1. Make it press CMD+SPACE
  2. type terminal.app
  3. press ENTER
  4. type echo -e "\xC2\xAF\\_(\xE3\x83\x84)_/\xC2\xAF" | pbcopy
  5. press ENTER
  6. press CMD+Q
  7. press CMD+V

though the user would see a terminal window for a second.

4
  • 4
    That's just plain nasty...
    – Majenko
    Aug 29, 2016 at 18:31
  • 1
    @majenko ¯_(ツ)_/¯
    – Gerben
    Aug 29, 2016 at 21:33
  • He has a broken arm... ):
    – Majenko
    Aug 29, 2016 at 21:34
  • 1
    @majenko I did copy paste it. If I try to edit the comment it's still there. So SO is doing something weird. Extra nastiness for free. (-:
    – Gerben
    Aug 29, 2016 at 21:38
2

It depends entirely on the operating system you are working with. The Arduino is merely a keyboard. It sends keystrokes. Whatever keystrokes your operating system will accept to generate unicode character are the keystrokes you have to program the Arduino to send. Most likely there is some combination of ALT-GR + keypad numbers that will do the trick.

For OS X it looks like the only possible way is to change the input settings on the computer to allow "Unicode HEX" entry.

There is no other way of doing it. As I say, the Arduino is just a keyboard. It is subject to the same rules as any other keyboard. You can only type things that can be typed. If you need to type other things the OS has to be made aware that you want to type those things through settings.

3
  • 1
    OP specifically mentions MacOS
    – Gerben
    Aug 29, 2016 at 18:24
  • Then it's anyone's guess what the keyboard combinations required might be then. Maybe something with the apple key (which is the same as the windows key). Either way the answer still stands - you have to find out the correct key sequences and send them as individual sequences.
    – Majenko
    Aug 29, 2016 at 18:25
  • If that involves making a change to the settings on the OS then that is what you have to do. There is no "magic wand" to type something that cannot be typed.
    – Majenko
    Aug 29, 2016 at 18:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.