• she/her

Principal engineer at Mercury. I've authored the Dhall configuration language, the Haskell for all blog, and countless packages and keynote presentations.

I'm a midwife to the hidden beauty in everything.

๐Ÿ’– @wiredaemon


discord
Gabriella439
discord server
discord.gg/XS5ZDZ8nnp
location
bay area
private page
cohost.org/newmoon

wiredaemon
@wiredaemon

Apple seems to think it knows best how a keyboard is supposed to work. Which is especially infuriating for german keyboard layouts.

The standard german keyboard layout makes heavy use of AltGr, which straight up doesn't exist on a MacBook keyboard. Instead, there are two command keys, which cannot be addressed individually through system settings.

I cannot tell you how funny it is when you try to type your email address in the setup guide and reach for the trusty AltGr + q key combination to type @, only for a pop-up to carefully ask you to please not kill the process of the setup program...

The reason, of course, is that cmd+q is the key combination to forcefully quit the process of the program currently in focus.

There are other oddities, like ~, and |. These aren't the worst, because they can still comfortably be typed by creating your own custom keyboard layout.

This is not the case for all AltGr dependent characters though. Annoyingly those are quite important characters like { [ ] } and \. It is possible to create a keyboard layout that simply requires pressing the option key instead of the missing AltGr, but the offset of that key makes typing extremely awkward, uncomfortable and borderline impossible if you have smaller hands.

Here is a trick, though: MacOS allows you to add a launch agent that hard-remaps keys! And in contrast to the system settings, you can do this for the right command key only! This means we can cheat our way towards a pseudo-AltGr key by making the right command key behave like another option key.

Just create a file under ~/Library/LaunchAgents/com.local.KeyRemapping.plist with the following content to remap the right command key to behave like an option key:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.local.KeyRemapping</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/bin/hidutil</string>
        <string>property</string>
        <string>--set</string>
        <string>{"UserKeyMapping":[
            {
              "HIDKeyboardModifierMappingSrc": 0x7000000E7,
              "HIDKeyboardModifierMappingDst": 0x7000000E6
            }
        ]}</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>

Combine this with a cursed custom german keyboard layout that doesn't have annoying deadkeys for ^, ~, etc., and you can suddenly use a MacBook for development, even if you have a german keyboard layout.

If anyone is interested in what that might look like, i've just uploaded that to a dedicated github repository:


You must log in to comment.

in reply to @wiredaemon's post:

Now I'm curious - if you're used to Windows keyboards, what's the advantage of remapping only the right Command/AltGr key, as opposed to swapping Command and Option on both sides? Option is the Mac equivalent of Alt anyway, so wouldn't that be more convenient for Windows muscle memory? (Or is it inconvenient/uncomfortable to use the Option keys in place of Command in key combinations?)

Regarding the rest of the keyboard layout differences: macOS does have a built-in "Deutsch โ€“ Standard" keyboard layout, which has all of the usual Windows AltGr-style combinations for brackets, braces, etc. instead of the Mac ones. The dead keys are identical to Windows too though - so Alt++ types ~ as a not-dead key, but ^ and ` are dead keys. Soo depending on how much those matter to you, the built-in layout may or may not be an alternative to your custom layout.

Of course, the built-in layout still uses the Option/Alt keys where Windows would use AltGr, so you still need the hidutil thing to put "AltGr" where you want it.

I wouldn't call it specifically windows keyboards, that Im used to but you're essentially right. there are a few things that bug me about the built-in keyboard layouts. But it goes beyond that. Copy is cmd+c so in case of switching the keys, hitting the option key which is between cmd and control feels really off for me. I. Would like the left control to still be control. On top of that, german Standard as you said still has dead keys. Especially for ^ i find that pretty unacceptable since i use that in vim to go the beginning of text in a line.

So what I wanted was "german standard" without dead keys and only replacing the right command with option and also have the other option combinations be more useful, like "ABZ QWERTZ" is

ah yeah, that makes sense. Thanks for elaborating!

The Ctrl/Cmd split is going to be hard no matter what you do, I assume, because it's not purely a keyboard layout thing. There's no way to "merge" Ctrl and Cmd, not even theoretically, because all software fundamentally expects them to be separate keys... The best you could do is swapping Ctrl and Cmd, which mostly works for GUI applications, but is absolutely terrible in the terminal.

What does "ABC โ€“ QWERTZ" even do? As far as I can tell, it's exactly identical to the regular German Mac layout, lol. (Or did you mean "ABC โ€“ Erweitert", the one that has Alt combinations for all the diacritics? "German โ€“ Standard" has most of those too, though not in the same places.)