Until everybody’s favorite entrepreneur Elon Musk sells his brain-to-computer interface Neuralink to the world, keyboards will be our main input source for computers. They’re the gateway between you and the connected hive mind that is the internet. People aren’t perfectly happy with this gateway (there is even an urban legend that Qwerty was designed to slow down typing) and many alternative layouts and form factors have been put forth.

German developers will program faster with this one weird trick

I, like many who learned programming on a German “Qwertz” keyboard, realized there is a low hanging fruit to be picked first: Switching to the US “Qwerty” keyboard. Immediately it becomes evident that the basic syntax of most programming languages was conceived by engineers who had easy access to their {s and `s.

There is a big drawback though: How can you continue to write German text with umlauts on a US keyboard? Solutions I have seen are:

  • Just typing transliterations (ae instead of ä). A very easy solution, but I find this unpleasant to read.
  • Switching keyboard layouts back and forth (using Super+Space). I used to do this, but after some time you’re not sure where exactly your ö hides on the keyboard.
  • Compose sequences. It’s cool to be able to type things like ⅔ and ©, but I don’t like having to press first Compose+Shift+2(→ ") and then Shift+a to get an Ä. It interrupts the my typing flow.
  • 3rd level choosers. You already know the concept: on a German keyboard’s 7 key, 1st level is 7, 2nd level is / and 3rd level is {.

Setting the 3rd level modifier key to something more convenient (I re-purposed caps lock) makes this last method the best one I know so far. Typing German words is very fast and feels natural.

Step 1: Patch the Xkeyboard config

Update (2020-11-14): This step is not necessary anymore on recent versions of Gnome! Instead, you can “Show Extended Input Sources” in Gnome Tweaks and then choose the “German, Swedish and Finnish (US)” layout. Details are at https://dev.to/kreait/how-to-enable-german-umlauts-on-us-intl-keyboard-in-arch-linux-k15

To enable umlauts on 3rd level I patched my Xkeyboard us symbols file, which lives at /usr/share/X11/xkb/symbols/us. Make sure you have a backup before messing with this!

Below is my diff to xkb-data v2.23.1‘s default us symbols file. You can see that it adds the symbols €üÜöÖäÄßẞ¢ (yes, that is a capital sharp s).

--- /usr/share/X11/xkb/symbols/us.backup
+++ /usr/share/X11/xkb/symbols/us
@@ -19,19 +19,19 @@
 
     key <AD01> {	[	  q,	Q 		]	};
     key <AD02> {	[	  w,	W		]	};
-    key <AD03> {	[	  e,	E		]	};
+    key <AD03> {	[	  e,	E,	EuroSign,	EuroSign	]	};
     key <AD04> {	[	  r,	R		]	};
     key <AD05> {	[	  t,	T		]	};
     key <AD06> {	[	  y,	Y		]	};
-    key <AD07> {	[	  u,	U		]	};
+    key <AD07> {	[	  u,	U,	udiaeresis,	Udiaeresis	]	};
     key <AD08> {	[	  i,	I		]	};
-    key <AD09> {	[	  o,	O		]	};
+    key <AD09> {	[	  o,	O,	odiaeresis,	Odiaeresis	]	};
     key <AD10> {	[	  p,	P		]	};
     key <AD11> {	[ bracketleft,	braceleft	]	};
     key <AD12> {	[ bracketright,	braceright	]	};
 
-    key <AC01> {	[	  a,	A 		]	};
-    key <AC02> {	[	  s,	S		]	};
+    key <AC01> {	[	  a,	A,	adiaeresis,	Adiaeresis	]	};
+    key <AC02> {	[	  s,	S,	ssharp,		U1E9E		]	};
     key <AC03> {	[	  d,	D		]	};
     key <AC04> {	[	  f,	F		]	};
     key <AC05> {	[	  g,	G		]	};
@@ -44,7 +44,7 @@
 
     key <AB01> {	[	  z,	Z 		]	};
     key <AB02> {	[	  x,	X		]	};
-    key <AB03> {	[	  c,	C		]	};
+    key <AB03> {	[	  c,	C,	cent	]	};
     key <AB04> {	[	  v,	V		]	};
     key <AB05> {	[	  b,	B		]	};
     key <AB06> {	[	  n,	N		]	};

You can get the full file from this Gist.

Step 2: Set the modifier key

The X keyboard 3rd-level modifier key lets you access these keys now. But what is the modifier key? Gnome users can use the tweak tools (see screenshot) to set it. In the end it will set xkb_symbols to include a modifier key from xkeyboard-config‘s available options. You can set it manually with something like
$ setxkbmap -option "lv3:caps_switch" us.

gnome-tweak-tools provides a GUI to set the 3rd level key

I like using caps lock as 3rd level modifier because otherwise it’s utterly useless and I find that ⇧ Shift+⇪ Caps Lock+a (which gives Ä) is quite easy to reach.

Step 3: Profit

Now go chat with your German friends and colleagues like a pro and write code in literally the way it was designed to be written.

Of course this setup is not perfect. Some people actually use caps lock as input language switch for Cyrillic keyboards (or to shout at strangers on the internet). The approach also requires local admin rights to change system files and is probably not what you want on multi-user machines.

Obviously this method won’t work in Windows. Here I can recommend SymWin, which is inspired by Apple’s iOS and OS X keyboard symbol selection. It may not be perfect, but when I use Windows I feel it improves my life already.

If you have an idea for an even better method, let me know!
Oh, and should you be close friends with Elon, I’m open to uploading my consciousness to achieve world domination beta testing Neuralink.