1

I would like to remap the Option+L/R shortcut on my Mac keyboard to Control+R/L. I don't want to use the modifier keys dialog because I only want to change these particular shortcuts. Any help would be appreciated. Bill

  • Just to avoid any confusion, by R/L I mean the right arrow and left arrow keys. – Bill R. Jan 28 '16 at 4:23
2

In the first example below Option-L/R arrow does the same after adjusting the keycodes as Control-L/R arrow.

The previous behavior Option-L/R arrow (e.g opening/closing a folder in list view) is lost.

If you want a different behavior you have to modify/precise your answer.

To make this work you have to use a third party tool: Karabiner.

  1. Download, install and open Karabiner
  2. Open in the menulet Karabiner -> Preferences
  3. Open the tab Misc & Uninstall
  4. Hit the button Open private.xml
  5. Open the file private.xml with an appropriate editor
  6. Enter the customized keycode

    <?xml version="1.0"?>
    <root>
      <item>
          <name>Change Option L/R arrow to Control L/R arrow</name>
          <identifier>altlr2ctrllr</identifier>
          <autogen>__KeyToKey__ KeyCode::CURSOR_LEFT, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_OPTION, KeyCode::CURSOR_LEFT, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_CONTROL</autogen>
          <autogen>__KeyToKey__ KeyCode::CURSOR_RIGHT, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_OPTION, KeyCode::CURSOR_RIGHT, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_CONTROL</autogen>
      </item>
    </root>
    
  7. Save the file

  8. Open in the menulet Karabiner -> Preferences the tab Change Key
  9. Hit the ReloadXML button
  10. Enable the remapping. It should be listed at the beginning.

And if you are really asking for "Option+L/R shortcut on my Mac keyboard to Control+R/L" - which can be read as alt-l to ctrl-r and alt-r to ctrl-l in contrary to the headline - then use

          <autogen>__KeyToKey__ KeyCode::CURSOR_LEFT, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_OPTION, KeyCode::CURSOR_RIGHT, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_CONTROL</autogen>
          <autogen>__KeyToKey__ KeyCode::CURSOR_RIGHT, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_OPTION, KeyCode::CURSOR_LEFT, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_CONTROL</autogen>

If you want the opposite (Control-L/R arrow does the same as Option-L/R arrow) use this snippet instead. The previous behavior of Control-L/R arrow is lost.

<?xml version="1.0"?>
<root>
  <item>
    <name>Change Control L/R arrow to Option L/R arrow</name>
    <identifier>ctrllr2altlr</identifier>
    <autogen>__KeyToKey__ KeyCode::CURSOR_LEFT, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_CONTROL, KeyCode::CURSOR_LEFT, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_OPTION</autogen>
    <autogen>__KeyToKey__ KeyCode::CURSOR_RIGHT, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_CONTROL, KeyCode::CURSOR_RIGHT, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_OPTION</autogen>
  </item>
</root>

If you want to swap ctrl-L/R-arrow with ctrl-L/R-arrow then use either both of the above keycode changes or this one:

<?xml version="1.0"?>
<root>
  <item>
    <name>Swap Control L/R arrow and Option L/R arrow</name>
    <identifier>swap_ctrllrarrow_altlrarrow</identifier>
    <autogen>__KeyToKey__ KeyCode::CURSOR_LEFT, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_OPTION, KeyCode::CURSOR_LEFT, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_CONTROL</autogen>
    <autogen>__KeyToKey__ KeyCode::CURSOR_RIGHT, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_OPTION, KeyCode::CURSOR_RIGHT, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_CONTROL</autogen>
    <autogen>__KeyToKey__ KeyCode::CURSOR_LEFT, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_CONTROL, KeyCode::CURSOR_LEFT, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_OPTION</autogen>
    <autogen>__KeyToKey__ KeyCode::CURSOR_RIGHT, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_CONTROL, KeyCode::CURSOR_RIGHT, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_OPTION</autogen>
  </item>
</root>
  • Thank you for the suggestion. Both your first and last code wont change the behaviour of ctrl-L/R. In both instances the cursor still moves to the far left and far right of the line. Option L/R behaves differently depending on the code: the first code doesnt change the behaviour, it still moves the cursor to the beginning of the previous or next word, while your last code disables option-R and changes option-L to switch to dashboard. – Bill R. Jan 29 '16 at 3:09
  • Which means that I still can't program Ctrl-L/R to do what I want, namely to move the cursor to the beginning of previous and next words respectively. I'm just wondering if Apple hasn't got some built-in protection of its own keyboard. – Bill R. Jan 29 '16 at 3:17
  • @BillR. Hmm the last and the second last do exactly what you want. In the last one (which is a new mod) ctrl-L/R-arrow behaves like alt-L/R-arrow and alt-L/R-arrow behaves like ctrl-L/R-arrow now. You have to disable all other mods made in private.xml in the Karabiner prefs though. – klanomath Jan 29 '16 at 11:22
  • @klanomath do you have a solution for a similar issue ? thanks - I don't know if this post is breaking 'stack rules' ...it's a related issue...anyway, I can remove it later on – jjrr Jan 22 '17 at 13:12
1

My knowledge of keyboard bindings is that it's difficult to do without installing third party applications. With that said, Karabiner (formerly KeyRemap4MacBook) provides a great way of customizing bindings easily, and should be able to do what you want.

  • I tried Karabiner and couldn't find these particular two shortcuts anywhere. I might be just missing it, so if anyone can confirm that it is possible in Karabiner and perhaps point to where I need to go to find them, I would be very grateful. – Bill R. Jan 28 '16 at 5:03
  • @BillR. That's quite possible. It may be possible to edit the XML file giving you greater control. Take a look and let me know if that works. – JMY1000 Jan 28 '16 at 5:06
  • Thanks for the advice. I looked at your suggestion to edit the XML file but I'm afraid its Greek to me. I'll need an 'average joe' solution for this one. – Bill R. Jan 28 '16 at 5:13
  • @BillR. Sorry, I'm afraid I don't know. I'll let you know if I think of anything. – JMY1000 Jan 28 '16 at 5:19

You must log in to answer this question.

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