splitbrain.org

electronic brain surgery since 2001

Unicode Macros on Keychron QMK/VIA

I recently bought a a Keychron K1 Pro keyboard. It runs the Open Source QMK/VIA firmware and it is quite easy to remap keys and create custom macros using the online interface at usevia.app.

Creating a macro that simply sends a couple of keystrokes is relatively straight forward. But I couldn't find a definite guide on how one would create a macro that inserts Unicode. But I figured it out in the end.

Since this is a keyboard, it can only send scancodes to the operating system. So we need to send the scancodes that make the OS combine them into a single UTF-8 character.

For Linux, you can enter unicode characters by pressing Ctrl-Shift-U, then enter the unicode code point in hex and press Enter.

For example Ctrl-Shift-U + 1f60a + Enter will insert a 😊.

In QMK macro language that translates to:

{KC_LCTL,KC_LSFT,KC_U}1f60a{KC_ENT}

If you want to send multiple Unicode characters, you need to keep repeating this for each character.

For example, ¯\_(ツ)_/¯ consists of the following characters:

  • ¯ U+00AF MACRON
  • \ U+005C REVERSE SOLIDUS
  • _ U+005F LOW LINE
  • ( U+0028 LEFT PARENTHESIS
  • U+30C4 KATAKANA LETTER TU
  • ) U+0029 RIGHT PARENTHESIS
  • _ U+005F LOW LINE
  • / U+002F SOLIDUS
  • ¯ U+00AF MACRON

So you can use the following macro code:

{KC_LCTL,KC_LSFT,KC_U}00af{KC_ENT}{KC_LCTL,KC_LSFT,KC_U}005c{KC_ENT}{KC_LCTL,KC_LSFT,KC_U}005f{KC_ENT}{KC_LCTL,KC_LSFT,KC_U}0028{KC_ENT}{KC_LCTL,KC_LSFT,KC_U}30c4{KC_ENT}{KC_LCTL,KC_LSFT,KC_U}0029{KC_ENT}{KC_LCTL,KC_LSFT,KC_U}005f{KC_ENT}{KC_LCTL,KC_LSFT,KC_U}002f{KC_ENT}{KC_LCTL,KC_LSFT,KC_U}00af{KC_ENT}

A macro like this is OS dependent, so the above only works for Linux. A more cross platform approach would be to use some kind of shortcut app on every OS you use and map the same keycombo in each of these apps to the same text to insert. But I like how this needs no additional software.

Tags:
keychron, qmk, via, macro, keyboard, howto
Similar posts: