Skip to content

Instantly share code, notes, and snippets.

@sebnyberg
Last active September 27, 2023 06:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebnyberg/3e59522486ebd451ae38ac3fb507da67 to your computer and use it in GitHub Desktop.
Save sebnyberg/3e59522486ebd451ae38ac3fb507da67 to your computer and use it in GitHub Desktop.
Mac + Moonlander + EN + SE

EN + SE on the Moonlander

I've been switching back and forth between English and Swedish for programming / chatting since.. forever.

Having bought the ZSA Moonlander, one of the goals was to eliminate switching.

There are two possible routes:

  1. Use a Swedish layout and put EN keys in better positions
  2. Use an English layout and somehow manage to insert åäö

Swedish layout

I used a Swedish layout for a while. But, the problem is that on Mac, some special characters (e.g. { and |) are generated by QMK by holding AltGr. When typing e.g. | and space in rapid succession, AltGr is applied to space, which turns the space from regular (0x20) to non-breaking space (0xc2a0). To add insult to injury, the non-breaking space is not visible in most editors, terminals and websites, so you get strange errors such as "grep could not be found" when piping, not because grep does not exist, but because <nonbreakingspace>grep does not.

⚠️ Fixing the non-breaking space ⚠️

It turns out that removing altgr+space is not so difficult. There's a rule called "Change alt+spacebar to spacebar" in the Karabiner Elements complex modifications online library. Et voila!

English layout (Unicode Hex Input)

Currently, I'm using approach 2) which is not great either, but works well for programming.

On Mac, there is a special keyboard layout called "Unicode Hex Input". While in this layout, unicode characters can be created by holding option and passing the unicode hex, e.g. 00C5 for Å.

For some reason however, the compiled layout on ZSA Oryx works for hex codes 00c5 (å), and 00f6 (ä), but when saving 00c4 (ä) to the keyboard, the flash will hang and fail, both with Wally and the online tool.

The current workaround is to map F11-F13 to the buttons I want åäö on, then map those to the option+keycode combination using Karabiner Elements.

Another issue with this option+keycode approach is that some websites have taken the liberty to bind Option- shortcuts, such as in Github where Option+f jumps forward one word, and Option+b jumps back. This means that the option hexcombination that is run by karabiner or the keyboard will jump around in the editor before inserting the character. Luckily, I rarely use åäö anywhere except chat clients that, so far, don't seem to have option bindings.

I also found that, for some reason, Karabiner elements slows down the modifier release when using complex rules like these. So when I type := (common in Go), I would get :+ instead. Inspecting the event viewer I could see how shift was not registering fast enough. Disabling the rules fixed the issue. For this reason, I ended up going back to Swedish + non-breaking-space fix.

For a list of keycodes, see https://character-table.netlify.app/swedish/

My current keyboard layout is here: https://configure.zsa.io/moonlander/layouts/Wg4pR/latest/0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment