User Tools

Site Tools


mac:keymap

KeyRemap4MacBook

KeyRemap4MacBook is an amazing tool that allows you to remap almost any key to any other. It works on any Mac computer not just MacBooks.

We initially started running KeyRemap4MacBook to put the Control key back in the corner where it belongs, instead of the Fn key. But we found some other really nice features, like hitting both Shift keys to turn on CapsLock.

Installation

KEYREMAP_VERSION=8.4.0
curl -O https://pqrs.org/macosx/keyremap4macbook/files/KeyRemap4MacBook-$KEYREMAP_VERSION.dmg
hdiutil attach KeyRemap4MacBook-$KEYREMAP_VERSION.dmg
sudo installer -pkg /Volumes/KeyRemap4MacBook-$KEYREMAP_VERSION/KeyRemap4MacBook.pkg -target /
hdiutil detach /Volumes/KeyRemap4MacBook-$KEYREMAP_VERSION
rm KeyRemap4MacBook-$KEYREMAP_VERSION.dmg

Configuration

To configure the key mapping, start KeyRemap4MacBook from the Applications directory.

  • Change Key
    • Change Fn Key
      • (laptop only) CHECK Fn+letter to Control_L+letter
    • Change Shift_L Key
      • CHECK Shift_R + Shift_L to CapsLock (+ Shift_L to turn CapsLock off)
    • Change Shift_R Key
      • CHECK Shift_L + Shift_R to CapsLock (+ Shift_R to turn CapsLock off)
    • For Applications
      • Enable at only Finder
        • Windows Explorer Navigation for Finder
          • CHECK Use F2 to Rename
          • CHECK Use Forward Delete as Delete Files
          • CHECK Cmd+R to Rename | Return to Open
      • Enable at only Terminal
        • CHECK Enable meta keys movement
    • Click ReloadXML button
  • Status Message
    • UNCHECK Show status message
  • MenuBar
    • UNCHECK Show icon in menu bar

Custom Bindings

To create custom bindings, you'll need to edit some XML. See the documentation for info on how to define the bindings.

  • Misc & Unintall
    • Open private.xml

Edit private.xml to add the following:

<?xml version="1.0"?>
<root>
 
  <item>
    <name>Custom Settings</name>
    <item>
      <name>Double-tap Shift to toggle CapsLock</name>
      <identifier>remap.double_tap_shift_to_toggle_capslock</identifier>
      <autogen>__DoublePressModifier__ KeyCode::SHIFT_L, KeyCode::SHIFT_L, KeyCode::CAPSLOCK</autogen>
      <autogen>__DoublePressModifier__ KeyCode::SHIFT_R, KeyCode::SHIFT_R, KeyCode::CAPSLOCK</autogen>
    </item>
    <item>
      <name>Shift+Fn To Paste (Command+V)</name>
      <identifier>remap.shift_fn_to_paste</identifier>
      <autogen>__KeyToKey__ KeyCode::FN, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_SHIFT, KeyCode::V, ModifierFlag::COMMAND_L</autogen>
      <not>TERMINAL, ITERM</not>
      <device_only>DeviceVendor::APPLE_COMPUTER, DeviceProduct::Keyboard_with_Numeric_Keypad</device_only>
    </item>
    <item>
      <name>Control+Fn To Copy (Command+C)</name>
      <identifier>remap.control_fn_to_copy</identifier>
      <autogen>__KeyToKey__ KeyCode::FN, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_CONTROL, KeyCode::C, ModifierFlag::COMMAND_L</autogen>
      <not>TERMINAL, ITERM</not>
      <device_only>DeviceVendor::APPLE_COMPUTER, DeviceProduct::Keyboard_with_Numeric_Keypad</device_only>
    </item>
    <item>
      <name>Fn To F19 (Terminal only)</name>
      <identifier>remap.fn_to_insert_in_terminal</identifier>
      <only>TERMINAL, ITERM</only>
      <autogen>__KeyToKey__ KeyCode::FN, KeyCode::F19</autogen>
      <device_only>DeviceVendor::APPLE_COMPUTER, DeviceProduct::Keyboard_with_Numeric_Keypad</device_only>
    </item>
    <item>
      <name>Control+PageDown (and PageUp) To Cycle Through Tabs (Control+Tab)</name>
      <identifier>remap.control_page_down_to_cycle_through_tabs</identifier>
      <only>TERMINAL, ADIUM</only>
      <autogen>__KeyToKey__ KeyCode::PAGEDOWN, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_CONTROL, KeyCode::TAB, ModifierFlag::CONTROL_L</autogen>
      <autogen>__KeyToKey__ KeyCode::PAGEUP, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_CONTROL, KeyCode::TAB, ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L</autogen>
    </item>
    <item>
      <name>Control+Return To Send Email (Command+Shift+D)</name>
      <identifier>remap.control_return_to_send_email</identifier>
      <autogen>__KeyToKey__ KeyCode::RETURN, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_CONTROL, KeyCode::D, ModifierFlag::COMMAND_L | ModifierFlag::SHIFT_L </autogen>
      <only>MAIL</only>
    </item>
  </item>
 
  <appdef>
    <appname>ADIUM</appname>
    <equal>com.adiumX.adiumX</equal>
  </appdef>
 
  <appdef>
    <appname>MAIL</appname>
    <equal>com.apple.mail</equal>
  </appdef>
 
  <appdef>
    <appname>ITERM</appname>
    <equal>com.googlecode.iterm2</equal>
  </appdef>
 
  <appdef>
    <appname>SUBLIME_TEXT</appname>
    <equal>com.sublimetext.2</equal>
    <equal>com.sublimetext.3</equal>
  </appdef>
 
  <deviceproductdef>
    <productid>0x024f</productid>
    <productname>Keyboard_with_Numeric_Keypad</productname>
  </deviceproductdef>
 
  <deviceproductdef>
    <productid>0x0262</productid>
    <productname>Internal_Keyboard_MacBook_Pro_Retina_Mid_2012</productname>
  </deviceproductdef>
 
</root>
  • Change Key
    • ReloadXML
    • CHECK the new custom settings
    • ReloadXML

TODO

  • Add <appendix> sections to provide more documentation.
  • Submit some of my custom bindings via a pull request on GitHub.
  • Consider configuring via command line instead of the GUI.
  • Try some chording combos, like the ASETNIOP bindings.
    • I'd probably prefer a customized Dvorak or Colemark layout.
  • Consider making the ESC key act as Hyper (Shift+Control+Option+Command) when held with another key.
mac/keymap.txt · Last modified: 2014/05/14 23:48 by Craig Buchek