all repos — site @ 72812b762c6aba86db69fc05d6eda26bb7575aab

source for my site, found at icyphox.sh

pages/blog/zmk-unicode.md (view raw)

 1---
 2template:
 3slug: zmk-unicode
 4title: Unicode text input in ZMK
 5subtitle: A hacky interim solution using macros
 6date: 2022-10-18
 7---
 8
 9As a highly cultured em-dash (over-)user, being able to type '—' easily
10is very important to me. While waiting for
11[zmkfirmware/zmk#232](https://github.com/zmkfirmware/zmk/issues/232) to
12get merged, I've discovered a rather nifty workaround for inputting
13Unicode text. This method makes use of
14[IBus](https://github.com/ibus/ibus) and a ZMK macro.
15
16Unicode input in IBus is done by typing `Ctrl` + `Shift` + `U` followed
17by the Unicode codepoint and then a `Space` or `Return`. Writing this
18as a ZMK macro, we get something like:
19
20```dts
21macros {
22    uc_dash: uc_dash {
23        label = "UNICODE_DASH";
24        compatible = "zmk,behavior-macro";
25        #binding-cells = <0>;
26        tap-ms = <0>;
27        wait-ms = <0>;
28        bindings
29            = <&macro_press &kp LCTRL &kp LSHFT>
30            , <&macro_tap &kp U>
31            , <&macro_release &kp LCTRL &kp LSHFT>
32            , <&macro_tap &kp N2 &kp N0 &kp N1 &kp N4 &kp SPC>
33            ;
34    }; 
35};
36```
37
38Where the numbers `2014` denote the codepoint for an em-dash. Set the
39`wait-ms` and the `tap-ms` to `0` to make it instantaneous -- your
40keyboard will essentially type out the entire key combo really fast. The
41resulting keycode `uc_dash` can be used in any `bindings` field. I have
42it on a separate Unicode layer.
43
44The unfortunate caveat is it only works where IBus works, and it doesn't
45seem to work in Qt applications. Granted, I only really need it in my
46browser and Signal/Slack Desktop (Electron) so that isn't a dealbreaker.
47
48My ZMK config is [here](https://github.com/icyphox/ferricy-zmk).