1

This is a follow up to How can I map the Windows key to option in Microsoft Remote Desktop version 8?. The answers to that question are a huge timesavers for OSX RDC users; however, there are some key combinations I don't want remapped. For example, Command+Q and Command+W would ideally still function the same as they do before remapping.

I tried adding this definition:

<autogen>
    __KeyToKey__ 
    KeyCode::Q, ModifierFlag::COMMAND_L, 
    KeyCode::Q, ModifierFlag::COMMAND_L
</autogen>

But to no effect.

Update: here is the full private.xml:

<root>
    <appdef>
        <appname>Microsoft Remote Desktop</appname>
        <equal>com.microsoft.rdc.mac</equal> 
    </appdef>
    <item>
        <name>Swap command and option in Remote Desktop</name>
        <identifier>private.remotedesktopswapcommandandcontrol</identifier>
        <only>Microsoft Remote Desktop</only>
        <autogen>
            __KeyToKey__ 
            KeyCode::Q, ModifierFlag::COMMAND_L, 
            KeyCode::Q, ModifierFlag::COMMAND_L
        </autogen>
        <autogen>__KeyToKey__ KeyCode::TAB, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_OPTION, KeyCode::TAB, ModifierFlag::COMMAND_L</autogen>
        <autogen>__KeyToKey__ KeyCode::OPTION_L, KeyCode::COMMAND_L</autogen>
        <autogen>__KeyToKey__ KeyCode::COMMAND_L, KeyCode::OPTION_L</autogen>
        <autogen>__KeyToKey__ KeyCode::OPTION_R, KeyCode::COMMAND_R</autogen>
        <autogen>__KeyToKey__ KeyCode::COMMAND_R, KeyCode::OPTION_R</autogen>
    </item>
</root>
1

The documentation suggests that these shouldn't conflict:

<autogen>
   __KeyToKey__
   KeyCode::Q, ModifierFlag::COMMAND_L | ModifierFlag::NONE,
   KeyCode::Q, ModifierFlag::COMMAND_L | ModifierFlag::NONE,
</autogen>
<autogen>__KeyToKey__ KeyCode::COMMAND_L, KeyCode::OPTION_L</autogen>

However, the second <autogen> will override the COMMAND_L of the first. The solution is counterintuitive:

<root>
    <appdef>
        <appname>Microsoft Remote Desktop</appname>
        <equal>com.microsoft.rdc.mac</equal> 
    </appdef>
    <item>
        <name>Swap command and option in Remote Desktop</name>
        <identifier>private.remotedesktopswapcommandandcontrol</identifier>
        <only>Microsoft Remote Desktop</only>            
        <autogen>__KeyToKey__ KeyCode::TAB, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_OPTION, KeyCode::TAB, ModifierFlag::COMMAND_L</autogen>
        <autogen>__KeyToKey__ KeyCode::OPTION_L, KeyCode::COMMAND_L</autogen>
        <autogen>__KeyToKey__ KeyCode::COMMAND_L, KeyCode::OPTION_L</autogen>
        <autogen>__KeyToKey__ KeyCode::OPTION_R, KeyCode::COMMAND_R</autogen>
        <autogen>__KeyToKey__ KeyCode::COMMAND_R, KeyCode::OPTION_R</autogen>
        <autogen>
            __KeyToKey__
            KeyCode::Q, VK_OPTION | ModifierFlag::NONE,
            KeyCode::Q, VK_COMMAND | ModifierFlag::NONE,
        </autogen>
    </item>
</root>

In this case Cmd+Q is remapped to Opt+Q but then Opt+Q is remapped back to `Cmd+Q'.

0

Make sure you add that autogen before the others:

Order of <autogen>

Basic case
KeyRemap4MacBook applies only the first matched <autogen>.

Source: https://pqrs.org/macosx/keyremap4macbook/xml.html.en


Try…

<autogen>
  __KeyToKey__
  KeyCode::Q, VK_COMMAND | ModifierFlag::NONE,
  KeyCode::Q, ModifierFlag::COMMAND_L
</autogen>
  • I tried that after reading the docs, but it doesn't seem to work. I updated the question to include the full XML I'm using. – wst Feb 13 '14 at 17:38
  • See edit (@wst) – grg Feb 13 '14 at 17:49
  • It seems (contrary to what the docs suggest) that __KeyToKey__ KeyCode::COMMAND_L, KeyCode::OPTION_L will always override KeyCode::Q, VK_COMMAND | ModifierFlag::NONE. I was actually able to get it working with the counterintuitive __KeyToKey__ KeyCode::Q, VK_OPTION | ModifierFlag::NONE, KeyCode::Q, VK_COMMAND | ModifierFlag::NONE, at the END. If you have a better solution, let me know. Or just update your answer with that, and I'll accept for the assist. – wst Feb 13 '14 at 18:51
  • @wst Interesting! That does seem strange, or I'm overlooking something… Feel free to self-answer — I don't think I could explain it as well as you and I wouldn't want to take credit. – grg Feb 13 '14 at 19:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .