Skip to content

Instantly share code, notes, and snippets.

@steinnes
Last active August 29, 2015 14:13
Show Gist options
  • Save steinnes/df65caf2d6e889952a27 to your computer and use it in GitHub Desktop.
Save steinnes/df65caf2d6e889952a27 to your computer and use it in GitHub Desktop.
Karabiner XML for MBP + Das Keyboard with Icelandic

I recently got a new mechanical keyboard named "Das Keyboard". I decided to go for the Brown Cherry MX keys which provide excellent tactile feedback while not being the absolute loudest there are.

I am using the keyboard with my 13" MacBook Pro Retina, which is connected to a Thunderbolt display, and it works .. mostly. I guess if it worked I wouldn't need to remap keys? ¯\_(ツ)_/¯

The Problem

So my only annoyance is the fact that the key next to 1 (or E00 according to ISO/IEC_9995) which on a normal US keyboard produces "" (grave) should with the Icelandic layout produce a diacritic ring which is used when writing danish letters like Å`.

With my Das Keyboard connected as I described here above it E00 produces the keycode which B00 should produce (<, > and |) and vice versa.

As a programmer I use the B00 button a lot because the symbols it produces (greater-than, less-than and pipe) are used as operators in most modern programming languages. I suppose issues like this are exactly the reason why a lot of my Icelandic colleagues choose to program using US or UK keyboard layouts. Let's face it: they are much less likely to be incorrect with any combination of software and hardware :-)

For most of my adult life however I've been a Linux user and although I don't know 100% how it is today, for the 10+ years I used Linux as my every day OS, being comfortable with manually binding your keys or generally fiddling with the system internals was pretty much a necessity -- so naturally I decided to do what I've done before: adjust.

Now after a couple of months I have given up adjusting, and why? Because when I disconnect my computer and take it home, I have to switch back to pressing ° to get my <, and the constant switching around basically got to be too much.

The Solution

To my rescue came the software Karabiner which allows you to do all kinds of crazy keybinding magic. I won't go into the details but with the help of a blog post by Ian Sinnott I crafted the tiny piece of XML linked here (private.xml) which roughly accomplishes this:

<?xml version="1.0"?>
<root>
<list>
<item>
<name>Switch 0xa and 0x32</name>
<identifier>private.steinn1</identifier>
<autogen>
--KeyToKey--
KeyCode::DANISH_DOLLAR,
KeyCode::BACKQUOTE
</autogen>
<autogen>
--KeyToKey--
KeyCode::DANISH_DOLLAR, ModifierFlag::SHIFT_R,
KeyCode::BACKQUOTE, ModifierFlag::SHIFT_R
</autogen>
<autogen>
--KeyToKey--
KeyCode::DANISH_DOLLAR, ModifierFlag::SHIFT_L,
KeyCode::BACKQUOTE, ModifierFlag::SHIFT_L
</autogen>
<autogen>
--KeyToKey--
KeyCode::BACKQUOTE,
KeyCode::DANISH_DOLLAR
</autogen>
<autogen>
--KeyToKey--
KeyCode::BACKQUOTE, ModifierFlag::SHIFT_R,
KeyCode::DANISH_DOLLAR, ModifierFlag::SHIFT_R
</autogen>
<autogen>
--KeyToKey--
KeyCode::BACKQUOTE, ModifierFlag::SHIFT_L,
KeyCode::DANISH_DOLLAR, ModifierFlag::SHIFT_L
</autogen>
</item>
</list>
</root>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment