Objective: A key which, when pressed, enters some sort of “hexadecimal unicode input mode”, where I type ~6 characters in hex, and the keyboard types the appropriate unicode codepoint. (Do any unicode characters have a hex code longer than 5 digits these days? I dunno.)
This doesn’t seem to be quite what the “leader” plugin does (I don’t think that the entire unicode table would quite fit into progmem), and I don’t see how to do it with a macro. Is there any easy way to satisfy this objective?
The only Plane that currently needs six hex characters is Plane 16, Private Use Area B, and it doesn’t seem that any of the various (non-standard) registries for Private Use Area codepoints have anything yet in that range.
The bigger problem, however, is that the keyboard is limited in what it can send to the operating system to only a relatively small set of keycodes.
There are other topics that already cover this in detail, e.g. Compose key(s) in firmware.
There’s the Unicode plugin that uses the operating-system dependent key sequence to type a given Unicode codepoints. I suppose you could add an event listener hook that would, when a given key is pressed, enter “Unicode input mode”, where it would ignore the pressed number keys (returning Key_NoKey) but keep track of which number was entered in a buffer, then when the max number of numbers have been entered, combine them to the given number and pass them to the Unicode plugin.
Unfortunately though, as far as I know, there isn’t a way for a keyboard to send a whole codepoint (limitation of the USB HID spec), so this would ultimately simulate pressing the OS key combination, which would pretty much amount to the same thing. At that point, it’d probably be easier to just map a key to the specific key sequence needed to type a unicode codepoint (C-M-s on Linux, hold option on macOS (with Unicode Hex Input as the input language), whatever it is on Windows). You may be interested in having a look at how the Unicode plugin works, in that case.
I would suggest a combination of the Unicode plugin, as James suggested, and Syster, a special input mode, that when triggered, captures keys until the next space, enter or escape, and runs them through a custom function. Combined with the Unicode plugin, you can use it to enter an unicode-input mode.
As an example, you can have a look at the src/Syster.cpp and src/SymUnI.cpp files in my sketch. These two implement a method where I press
LEAD u, and enter unicode input mode. It prints a keyboard emoticon first, waits for the next space/enter/esc, looks at the stuff typed, if it finds the string in the pre-programmed list, it inputs the appropriate hex code, otherwise it starts the OS-specific unicode input mode, and re-types whatever you typed. This allows me to do
LEAD u coffee SPC, and end up with
☕, or type
LEAD u 03bb and end up with
I think this is pretty close to what you want: you can input unicode symbols by name (by having a few hard-coded), and input the rest by hex code.
Wow, that looks great! I’ll try it shortly. Thanks!