The German keyboard layout is excessively stupid. For programmers, that is.
It is a QUERTZ layout in which the most notable difference from the standard U.S. QUERTY layout is that the Z is swapped for Y. That in itself isn’t the problem. The problem is that the German keyboard needs to contain umlauts (which are necessary in the German language). These umlauts are placed where the U.S.keyboard places all those keys useful to programmers: :;, [], {}, \ and |. These characters are still typable on a German keyboard, but one needs to use the right Alt key (which is called AltGr for alternate graphics) together with some number keys on top. To see what a typical German keyboard looks like, take this schema from Wikipedia:
As you can see, typing @, [], {}, \, and | requires you to leave the typical home-row position that touch typers like myself prefer.
On the Mac
All that is even worse on the Mac. The basic layout is the same, but the Mac doesn’t have the AltGr key. It has the Mac-specific Option key (which is also labeled “alt”) which is used to access special characters that aren’t avialable in standard layouts. This is used to access things like @, [], {}, \ and |. The only problem is that a) the keys that these are accessed from are not the ones on the PCs with the AltGr combination and b) their position isn’t printed on the keys at all!
Solution: Teach the U.S. layout umlauts
Physically, my PowerBook has a German keyboard, but 90% of the time I use the U.S. keyboard layout. It’s much more convenient for programming, out of all the reasons stated above. However, during the remaining 10% of the time I still have to write German text that might contain umlauts. That’s why I have to switch between the U.S. layout and the German layout a lot. Often, my email application is using the the German layout while Emacs is running under the U.S. layout. It confuses the heck out of me when switching back and forth and I often end up tzping “partz” and “Yope,” for example.
A long time ago, the German Linux Magazin had an article on how to teach the U.S. layout umlauts to avoid this dilemma. Basically, you would take a bare U.S. layout, turn the right Alt key into AltGr and make the combinations AltGr+A, AltGr+O, and AltGr+U produce the respective umlauts.
This solution fits me perfectly, as I can afford to use nasty AltGr combinations in 10% of the time while having the productive layout 90% of the time. Using AltGr combinations but sticking to one layout would certainly not be as confusing as switching between layouts.
Home-made layouts on the Mac
Alas, the solution they presented obviously is for Linux; X11 to be exact. Fortunately, it isn’t hard to supply your own keyboard layout in Mac OS X. Keyboard layouts are typically stored in XML files (or in absolutely inscrutable resource files) and are put into either ~/Library/Keyboard Layouts or /Library/Keyboard Layouts. The hard part about them is writing them. The XML format might be human readable, but certainly not human understandable.
Luckily, there’s Alex Eulenberg’s keyboard layout generator which allows you to create the keyboard layout XML files (or resource files) using a very simple script. You can either start out with a blank keyboard layout and script every single key, or take the QUERTY or Dvorak keyboard and go from there.
I chose the QUERTY presetting and defined my umlauts based on the following script:
- Oa $00e4 :: auml
- OSa $00c4 :: Auml
- Oo $00f6 :: ouml
- OSo $00d6 :: Ouml
- Ou $00fc :: uuml
- OSu $00dc :: Uuml
- Os $00df :: szlig
- On $00f1 :: ntilde
- OSn $00d1 :: Ntilde
- Oe $20ac :: euro
This will essentially allow me to press the Option (“alt”) key and then either one of a, A, o, O, u, U to get the respective umlaut. In addition, I get the sz ligature for Option-s, the euro for Option-e and the Spanish n-tilde for Option-n.
Last, I had to choose the encoding for the keyboard layout. After having generated a few layouts, I found out that choosing Roman has the advantage, that the layout will be available in non-unicode aware apps, such as Carbon-based ones. It is perfectly fine to use Roman for German characters since it contains umlauts and other western European characters (in fact, the original German keyboard layout also uses Roman).
The resulting XML file has to be saved with the keylayout extension and placed in one of the library paths. The Alex’s page mentions that it might not be necessary to log out and log in again after that. However, I had to log out and log in again every time so see the changes I had made to the keyboard layout directories.
Leave a Reply