Posted

Jan 15, 2016

Tags

Customizing OS X keyboard layout for Finnish programmers (Might apply to other countries also)

Finnish "programmers" keyboard layout configuration using Karabiner App.

Took a risk this week and started using OS X and soon noticed that even the keyboard has Finnish layout it is completely different from what I've used to with Linux and Windows. I do have possibility to have external keyboard but as am using MacBook and there is a risk that I might need to work from home, it is better to learn the actual keyboard. But am not willing to completely change my key combinations that I've used to.

So off to kill the problem, after googling around found that I do need to use Karabiner App. By first descriptions I had doubts that could succeed with what I want, but after fiddling with the xml file I was able to come up with some kind of solution that fits my bill. I try to keep this short and just explain a bit what did and then just slam in the xml file.

The keys I needed to for PHP programming with old key combinations that were in odd positions: { [ ] } ~ @ $ \ so basically all that are behind AltGr with PC keyboards. First I needed the AltGr for that I sacrificed the right hand side Command key. I have no idea what I could use it for so it was easy to get rid of. This does rise small issues but I'll explain it after the xml file. You might need to do some “bubblegum” fixes afterwards. First I did assign the alt+ctrl combo to command key and after that bound each key I wanted to override to use that as modifier flags.

How to read the file? Name and identifier are quite self explanatory really, name is what shows in the application and identifier is unique id for the item. More important now is what is on autogen after __KeyToKey__. The first line is the key I want the modification to apply, and second line is what keypress it should mimic. As karabiner goes top-down, the AltGr comes first. Some of the hex values were not directly available through documentation and online hex lists had incorrect values as seems like that OS X likes to play around with them also. To get correct KeyValue I used KeyCodes App. So enough of this and here is the private.xml file.

<?xml version="1.0"?>
<root>
    <symbol_map type="KeyCode" name="PIPE" value="0x7c" />
    <item>
        <name>R_CMD as Alt Gr.</name>
        <identifier>private.altgr</identifier>
        <autogen>
            __KeyToKey__
            KeyCode::COMMAND_R,
            KeyCode::SHIFT_L, ModifierFlag::OPTION_L
        </autogen>
    </item>
    <item>
        <name>Add PIPE to right place</name>
        <identifier>private.pipe</identifier>
        <autogen>
            __KeyToKey__
            KeyCode::RawValue::0x32, ModifierFlag::SHIFT_L | ModifierFlag::OPTION_L,
            KeyCode::7, ModifierFlag::OPTION_L
        </autogen>
    </item>
    <item>
        <name>Add Dollar symbol to right place</name>
        <identifier>private.dollar</identifier>
        <autogen>
            __KeyToKey__
            KeyCode::RawValue::0x15, ModifierFlag::SHIFT_L | ModifierFlag::OPTION_L,
            KeyCode::4, ModifierFlag::OPTION_L
        </autogen>
    </item>
    <item>
        <name>Left Bracket</name>
        <identifier>private.lbrack</identifier>
        <autogen>
            __KeyToKey__
            KeyCode::RawValue::0x1c, ModifierFlag::SHIFT_L | ModifierFlag::OPTION_L,
            KeyCode::8, ModifierFlag::OPTION_L
        </autogen>
    </item>
    <item>
        <name>Right Bracket</name>
        <identifier>private.rbrack</identifier>
        <autogen>
            __KeyToKey__
            KeyCode::RawValue::0x19, ModifierFlag::SHIFT_L | ModifierFlag::OPTION_L,
            KeyCode::9, ModifierFlag::OPTION_L
        </autogen>
    </item>
    <item>
        <name>Left Curly</name>
        <identifier>private.lcurly</identifier>
        <autogen>
            __KeyToKey__
            KeyCode::RawValue::0x1a, ModifierFlag::SHIFT_L | ModifierFlag::OPTION_L,
            KeyCode::8, ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L
        </autogen>
    </item>
    <item>
        <name>Right Curly</name>
        <identifier>private.rcurl</identifier>
        <autogen>
            __KeyToKey__
            KeyCode::RawValue::0x1d, ModifierFlag::SHIFT_L | ModifierFlag::OPTION_L,
            KeyCode::9, ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L
        </autogen>
    </item>
    <item>
        <name>Backslash</name>
        <identifier>private.backslash</identifier>
        <autogen>
            __KeyToKey__
            KeyCode::RawValue::0x1b, ModifierFlag::SHIFT_L | ModifierFlag::OPTION_L,
            KeyCode::7, ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L
        </autogen>
    </item>
    <item>
        <name>Tilde</name>
        <identifier>private.tilde</identifier>
        <autogen>
            __KeyToKey__
            KeyCode::RawValue::0x1e, ModifierFlag::SHIFT_L | ModifierFlag::OPTION_L,
            KeyCode::RawValue::0x1e, ModifierFlag::OPTION_L
        </autogen>
    </item>
    <item>
        <name>At</name>
        <identifier>private.at</identifier>
        <autogen>
            __KeyToKey__
            KeyCode::2, ModifierFlag::SHIFT_L | ModifierFlag::OPTION_L,
            KeyCode::RawValue::0x13, ModifierFlag::OPTION_L
        </autogen>
    </item>
    <item>
        <name>R CMD ENTER to Normal</name>
        <identifier>private.enter</identifier>
        <autogen>
            __KeyToKey__
            KeyCode::RETURN, ModifierFlag::SHIFT_L | ModifierFlag::OPTION_L,
            KeyCode::RETURN, ModifierFlag::COMMAND_R
        </autogen>
    </item>
</root>

The file put's all the required (for me) to correct places, last one is to get back the command + return which is used by Facebook chat for example to send new message. Could go on forever like I usually do, but hopefully this helps those who are struggling with the same problem. And I guess if you are reading this from other country and are a programmer. You'll definitely know how to get those keys you need to their correct spot. Another advantage with the Karabiner is that you can change key repeat time, this came handy when using shell and pressing down backspace was slow as snail.

Also I would suggest to install BetterTouchTool for mouse configuration, it gives lot more customization options for mouse keys and comes with window snap, for example it gives you the simple methods to drag app to side of the screen and it'll take automatically 50% of screen width and 100% of height. I guess that was useless point unless you did not know the feature on windows/some window managers on linux.

Share your Thoughts

0 Responses

Your email address will not be published

Please enter your name.
Please enter valid email address.
Please enter your website address.
Please enter your message.
TwitterX Error: Could not load tweets as Twitter responded with the error: 'Invalid or expired token.'.
-->

Contact me with email or add my account to skype

the_dunnock@outlook.com

the_dunnock@outlook.com