This is from a long time ago, but I had the same question just now and ended up on this answerless page, so, hereās the (an?) answer.
If you want a macro to produce then you have at least a couple of options that Iāve worked out. Both of them use the UHK macro </> Command action and both require that you turn on Appleās Unicode Hex Input.
To turn on Unicode Hex Input:
Open System Preference
Select Keyboard
Select the Input Sources tab
Click the + button thatās underneath the left pane
Scroll to the very bottom of the list of languages and click on Others (you canāt type that in the search box)
Click on Unicode Hex Input on the right and then Add
Once thatās enabled, youāll be able to press and hold the left-option (or Alt) key and type letters/numbers to have them interpreted as a UTF-16 encoded character.
If you need to use a different input source by default (e.g. you type in German or French or some other language that has a different keyboard layout then thereās a shortcut key that you can set and then use in your macro. To enable the shortcut key (and change it if you wish, because by default it clashes with Spotlight):
Open System Preference
Select Keyboard
Select the Shortcuts tab
Select Input Sources from the left pane
Enable and modify the two input source selectors
OK, finally, you can set up your macro! As stated, you have at least two options:
Three lines, but easier to copy/paste unicode strings into:
holdKey sLA
write "D83DDE00"
releaseKey LA
This uses holdKey to press and hold the Left Alt (or āOptionā on the Mac) key. Note the prepended s, that sets the āsticky modifierā which means that this modifier applies to the subsequent key press events.
write will type the provided string (I guess itās probably the equivalent of press/release for each key).
releaseKey does the obvious.
Single line, but youāll have to space out the Unicode: tapKeySeq sLA D 8 3 D D E 0 0
tapKeySeq does the same thing as option 1, but requires you to type out each character of the D83DDE00 string space-separated, so the macro knows which individual keys to āpressā. Iām not sure if you need to reset the sticky modifier anywhere but my reading of firmware/doc-dev/reference-manual.md at master Ā· UltimateHackingKeyboard/firmware Ā· GitHub makes me suspect not (next keypress should cancel it).
One important note! The string Iām using is D83DDE00 which is the UTF-16 encoding for - see the page at https://www.compart.com/en/unicode/U+1F600 for an example of the various different ways that these characters can be encoded.
The UTF-32 Encoding is often the default on various websites but macOS expects UTF-16 for historical reasons so you need to use that version. Youāll see these numbers presented like 0x0001F600 (UTF-32) and 0xD83D 0xDE00 (UTF-16). The 0x is just a convention to indicate that the following number is hexadecimal, and you donāt need to include it when sending key presses for Unicode-interpretation.
Interesting! I donāt know if itās a bug, or Operating System variance (Iām running macOS 12.7.5) or if I just donāt understand how things are working but, for what itās worth, without that s this macro doesnāt work for me.
With the following macro I get š:
holdKey sLA
write "D83DDE42"
releaseKey LA
With this one I get D83DDE42:
holdKey LA
write "D83DDE42"
releaseKey LA
Also, Iāve expanded the macro to automatically toggle to the Unicode mode (because I need to be able to use a different input mode normally). I have set the keyboard shortcut Ctrl+ā+Alt+i to Select next source in Input menu and I have two input sources now so adding a leading and trailing tapKey LCLALG-i to the macro toggles the mode as part of the macro now.
For completeness, the current macro now looks like:
tapKey LCLALG-i
holdKey sLA
write "D83DDE42"
releaseKey LA
tapKey LCLALG-i
You donāt need the L for each of the control keys, CAG-i will work just the same, but they were the ones I pressed to create the shortcut, so I just ran with it.
Hmpf. Allright, in that case macOS apparently requires prolonged press of the alt. That could also be done by inserting a delay (like delayUntil 200 just before the releaseKey LA) instead. But I can see that sLA is more convenient .
Nope, I tried removing the s and adding delayUntil 200 as the fourth line (between the write and the releaseKey) and it didnāt work. I also tried extending the delay, just in case that helped but 2000 and then 20000 made no difference (and Iām sure itās running, because with the longer delay I can visually watch the input source icon changing).
Iāll have access to an alternate macOS machine with a different OS next week. Iāll try it out there and see if the same thing happens.
If you have time, Iād be interested in understanding what the s actually does and how it compares (in theory) to the delayuntil. Iām not sure I really understand the Reference Manual because my reading of that is that the D that the write sends should āreleaseā the sticky modifier, although perhaps it actually holds until the 2, because the write acts as an atomic action?
I have forgotten that in the same macro those pressKey and write use the same usb report buffer, so the write clears the modifier masks.
Anywayā¦ In practice, sticky modifier mask doesnāt get cleared because it is processed differenty - it is stored in an independent global variable. It is then cleared once next key is physically pressed.
As for the purpose of sticky modifiers, assume standard Windows Alt+Tab behavior. Now map UHK so that mod+tab produces (sticky) alt+tab (sLA-tab in macro notation). The point of the sticky modifier mode is to make uhk keep alt pressed between the tab taps in mod+tab+tab, which is needed for proper window switching function. (So the fact that it doesnāt get cleared by write is correct, although it was not designed to be used the way you did.) Formally sticky modifier is active until next key action is activated (by a physical key press) or until the layer it was issued from is released.
You have read the Reference Manual wrong because the manual ambiguously states āuntil next key pressā, without clarifying that the author (me) meant next physical key press rather than next produced scancode. I will fix the documentation shortly.