So I've got a Moonlander. One of those fancy keyboards: ZSA lists it at 365 US dollars, which for me in Europe came to around 400 euros.1 It is split, so each hand gets its own half. It tents, so your wrists are not flat all day. The keys sit in straight columns instead of staggered rows, each thumb gets its own cluster of keys, the switches are hot-swappable and every key has its own light.
ZSA, who make it, have been building these since 2015, when they crowdfunded the ErgoDox EZ,2 a ready-made version of the ErgoDox, an open-source split keyboard people used to build themselves.3 You configure all of them in Oryx, ZSA's web editor: click a key, pick what it does, and Oryx builds the firmware.4
I unboxed mine in September 2023.5 Back then I did what most people do: I switched between the US and Swedish keyboard layouts in the operating system and called it a day. It mostly worked. But some things never stopped bugging me, and every time one did I fixed that one key in Oryx and flashed again. Most of those fixes came from coding in PhpStorm, where a bracket in the wrong place or a symbol that needs three fingers is something you notice a hundred times a day.
One key at a time never added up to a layout. Today I finally sat down and built the whole thing I had always wanted, for the three languages I actually write in: English, Swedish and European Portuguese.
What was broken
My system runs in English, but my keyboard layout is Swedish, because I need å, ä and ö. Keyboard firmware assumes a US layout unless you tell it otherwise.6 So the key you press and the character you get disagreed in about a dozen places:
The board glowed the same blue on every layer, so I never knew which layer I was on.
On the symbols layer, the key Oryx showed as
@typed",{typedÅ, and so on. Those were US keycodes going through a Swedish layout.There was no AltGr key,7 and on the Swedish layout AltGr is how you type
@ £ $ { [ ] } \ |.Å, Ä and Ö had taken the places of
[,'and;, and nothing had brought those back.Portuguese needs
ç,ã,õ,ê,ºandª. None of them had a key.
Oryx for the layout, QMK for the rest
Oryx cannot change what AltGr+C does, and it cannot make a key glow red only while Caps Word is on. For that you need QMK, the firmware underneath. ZSA keeps its own fork of QMK, which is what Oryx builds from.8
The usual options are to export from Oryx and stop using it, or a project like oryx-with-custom-qmk, which merges Oryx's export with your own code in GitHub Actions.9 I wanted the same idea on my own machine, so a small script, ml, keeps a git repository with two branches:
oryxholds exactly what Oryx exports.mainis that export plus one extra file,custom.c, for what Oryx cannot do.
ml fetch # newest revision from Oryx's API, committed to `oryx`, merged into `main`
ml build # compile in QMK's own container (podman), no toolchain on the host
ml flash # wait for the bootloader, then flash with dfu-util
The original firmware is backed up, and ml flash with that file puts the board back as it was.
Colours
The blue was a single setting. Oryx has a "toggle layer colours" key, I had pressed it at some point, and the setting is stored on the keyboard, so it survived every flash. Pressing it again fixed it, and custom.c now draws the layer colour regardless.
Primary is teal, Symbols is orange, the third layer is pink. The keys that switch layers glow in the colour of the layer they lead to: on teal, the keys into Symbols are orange; on orange, the same keys are teal because they lead back. Keys that do nothing on a layer are off. Oryx can set a colour per key per layer, so all of this lives in the Oryx layout rather than in code.
Symbols that type what they show
On the Swedish layout, @ is AltGr+2. A US @ keycode sends Shift+2, which on the Swedish layout is ". Every symbol key on the second layer needed its Swedish keycode instead. QMK has a full set for this (SE_AT, SE_LCBR and so on, in keymap_swedish.h),6 and with those each key sends whatever the Swedish layout needs to produce the symbol it shows.
The keys that Å, Ä and Ö had pushed out got new places on the symbols layer, next to the other brackets.
On the Swedish layout ^, ~ and ` are dead keys: nothing appears until you press the next key, because it is waiting to put an accent on a letter.10 Fine for writing, annoying for code. On the symbols layer, custom.c sends the symbol followed by a space, so it appears straight away.
AltGr and the accent key
AltGr went on the lowest key of the right thumb cluster. That made AltGr+2 for @, AltGr+E for € and the rest of the Swedish layout's AltGr symbols work.
The ¨ key sits right of Å on a Swedish keyboard. It is a dead key too: it puts an accent on the next letter you type. My layout had lost it, so ü and ã were impossible. It is now the tap on the bottom-left key, whose hold still switches to Symbols:
| Press | Then | You get |
|---|---|---|
| ¨ | u, e, i | ü ë ï |
| Shift+¨ | a, e, o | â ê ô |
| AltGr+¨ | a, o, n | ã õ ñ |
| ´ | a, e, o | á é ó |
The key below Ä now types ' when tapped and acts as Shift when held. QMK calls that a mod-tap.11
Portuguese
A Portuguese keyboard has its own key for ç. I had no key to spare, so the Portuguese extras use AltGr plus a letter:
AltGr+C gives
ç, AltGr+Shift+C givesÇ.AltGr+A gives
ª, as in primeira. The Swedish layout already had this one.AltGr+O gives
º, as in primeiro.
The last two are the ordinal indicators Portuguese writes after numbers, as in 1º and 1ª.12
Oryx cannot change what AltGr does to a letter, so this is most of what custom.c is for. The cedilla is the Swedish layout's dead cedilla (AltGr+Comma) followed by the letter:
if (keycode == KC_C && (get_mods() & MOD_BIT(KC_RIGHT_ALT))) {
uint8_t mods = get_mods();
clear_mods();
tap_code16(RALT(KC_COMMA)); // dead cedilla on the Swedish layout
tap_code16(mods & MOD_MASK_SHIFT ? S(KC_C) : KC_C);
set_mods(mods);
return false;
}
The other thing custom.c does is light both Shift keys red while Caps Word is on.13
What went wrong
Colour code that did nothing. My first attempt at the layer-key colours was QMK code. It compiled, flashed, and changed nothing: QMK draws the LEDs in chunks, and Oryx's code repaints every key in the layer colour at the end of each frame. Moving it to the indicator hook that runs once per frame fixed it,14 and later the colours moved into Oryx anyway.
Editing Oryx by script. I had an assistant do the clicking in Oryx through the browser. Fine for single keys, bad for seventy. It ended up editing the wrong key, and a stray Escape press landed in a "press a key" field and turned my Enter key into Super. What worked was sending the editor's own API call for each key, with the known good key data and only the colour changed, then comparing the whole layout against the last good version before compiling.
The bootloader window. The flash script waited sixty seconds for me to put the board in bootloader mode. Not long enough. It waits three minutes now.
The layout and the code
Layout: dotMavriQ's Definitive Trilingual on Oryx. Every key on every layer, colours included. You can open it, try it in Oryx's tester, or copy it into your own account.
Code: dotMavriQ/moonlander-trilingual on GitHub. The
custom.cwith everything Oryx cannot do, themlscript, and the Oryx export it builds on.
Still to do
The LEDs could show the volume level or the current desktop, and the instant ^ ~ ` could move from code into Oryx macros so the Oryx page shows everything.
Footnotes
ZSA, Moonlander Mark I. Price "from USD $365, shipping included"; split halves, tenting and tilting, an articulating thumb cluster, hot-swappable switches and RGB lighting under each key. ↩
ZSA, ErgoDox EZ: "since our successful crowdfunding campaign all the way back in 2015." ↩
ErgoDox, the original open-source project, available as a DIY kit or assembled. ↩
ZSA, Oryx, the web configurator that "makes firmware for your board." ↩
Unboxing My New Setup, my own YouTube Short from 11 September 2023: a Beelink SER6 and the Moonlander. ↩
QMK documentation, Language-specific keycodes. The default keycodes assume US ANSI; headers such as
keymap_swedish.hgive the keys their names for other layouts, which "you still have to set" in the operating system. ↩ZSA, qmk_firmware: "QMK, forked for ZSA's Oryx Configurator… This is the repo that Oryx pulls from." ↩
oryx-with-custom-qmk, a community project that adds QMK features to an Oryx layout and builds the firmware with GitHub Actions. ↩
QMK documentation, Mod-Tap: a key that "acts like a modifier when held, and a regular keycode when tapped." ↩
Ordinal indicator, Wikipedia, on º and ª in Portuguese, Spanish, Italian and Galician. ↩
QMK documentation, Caps Word, "a modern alternative to Caps Lock." ↩
QMK documentation, RGB Matrix: Indicators. ↩