pqrs-org / Karabiner-archived

Karabiner (KeyRemap4MacBook) is a powerful utility for keyboard customization.
https://pqrs.org/osx/karabiner/
The Unlicense
3.82k stars 309 forks source link

Question: How to Remap Option+Letter keys? #362

Closed kylebrandt closed 9 years ago

kylebrandt commented 9 years ago

For example I would like to turn option+d into a [. When doing this I still end up with a rounded d (∂).

I have tried:

    <item>
        <name>option+d to {</name>
        <identifier>remap.optd_to_curly</identifier>
        <autogen>
            __KeyToKey__ 
            KeyCode::D, 
            ModifierFlag::OPTION_L | ModifierFlag::OPTION_R,
            KeyCode::BRACKET_LEFT,
        </autogen>
    </item>

EventView output:

image

kylebrandt commented 9 years ago

Managed to figure it out I think:

        <autogen>
            __KeyToKey__ 
            KeyCode::D, VK_OPTION | ModifierFlag::NONE,
            KeyCode::BRACKET_LEFT,
        </autogen>

However I still don't understand what was wrong with my other one, or how this one works. I just adapted https://pqrs.org/osx/karabiner/faq.html.en#unicode-hex-input and got lucky....

tekezo commented 9 years ago

ModifierFlag::OPTION_L | ModifierFlag::OPTION_R means "if both the left option key and the right option key are pressed".


The second

        <autogen>
            __KeyToKey__ 
            KeyCode::D, VK_OPTION | ModifierFlag::NONE,
            KeyCode::BRACKET_LEFT,
        </autogen>

will be expanded two autogens:

        <autogen>
            __KeyToKey__ 
            KeyCode::D, ModifierFlag::OPTION_L | ModifierFlag::NONE,
            KeyCode::BRACKET_LEFT,
        </autogen>
        <autogen>
            __KeyToKey__ 
            KeyCode::D, ModifierFlag::OPTION_R | ModifierFlag::NONE,
            KeyCode::BRACKET_LEFT,
        </autogen>
kylebrandt commented 9 years ago

Thanks for explaining. I even read about the pipe in the documentation but inserted it to mean "or" in my head :-P