Skip to content

Instantly share code, notes, and snippets.

@ELLIOTTCABLE
Created November 12, 2011 02:52
Show Gist options
  • Select an option

  • Save ELLIOTTCABLE/1359957 to your computer and use it in GitHub Desktop.

Select an option

Save ELLIOTTCABLE/1359957 to your computer and use it in GitHub Desktop.
Remapping top 21 keys of Apple keyboard to be *all* function keys.
<?xml version="1.0"?>
<root>
<item>
<name>Change top row to 'all function keys'</name>
<appendix>Change Escape to F1</appendix>
<appendix>Change F1..F12 to F2..F13</appendix>
<appendix>Change Eject to F14</appendix>
<appendix>Change F13..F19 to F15..F21</appendix>
<appendix>(Best used with PCKeyboardHack to use Caps Lock as escape,</appendix>
<appendix> and NoEjectDelay to safely remap eject.)</appendix>
<identifier>private.topkeys_to_f1_f13</identifier>
<autogen>--KeyToKey-- KeyCode::ESCAPE, KeyCode::F1</autogen>
<autogen>--KeyToKey-- KeyCode::F1, KeyCode::F2</autogen>
<autogen>--KeyToKey-- KeyCode::F2, KeyCode::F3</autogen>
<autogen>--KeyToKey-- KeyCode::F3, KeyCode::F4</autogen>
<autogen>--KeyToKey-- KeyCode::F4, KeyCode::F5</autogen>
<autogen>--KeyToKey-- KeyCode::F5, KeyCode::F6</autogen>
<autogen>--KeyToKey-- KeyCode::F6, KeyCode::F7</autogen>
<autogen>--KeyToKey-- KeyCode::F7, KeyCode::F8</autogen>
<autogen>--KeyToKey-- KeyCode::F8, KeyCode::F9</autogen>
<autogen>--KeyToKey-- KeyCode::F9, KeyCode::F10</autogen>
<autogen>--KeyToKey-- KeyCode::F10, KeyCode::F11</autogen>
<autogen>--KeyToKey-- KeyCode::F11, KeyCode::F12</autogen>
<autogen>--KeyToKey-- KeyCode::F12, KeyCode::F13</autogen>
<!-- F14 might be reserved by system -->
<!-- F15 might be reserved by system -->
<autogen>--ConsumerToKey-- ConsumerKeyCode::EJECT, KeyCode::F14</autogen>
<autogen>--KeyToKey-- KeyCode::F13, KeyCode::F15</autogen>
<autogen>--KeyToKey-- KeyCode::F14, KeyCode::F16</autogen>
<autogen>--KeyToKey-- KeyCode::F15, KeyCode::F17</autogen>
<autogen>--KeyToKey-- KeyCode::F16, KeyCode::F18</autogen>
<autogen>--KeyToKey-- KeyCode::F17, KeyCode::F19</autogen>
</item>
</root>
@ELLIOTTCABLE
Copy link
Author

Usage

First, install @tekezo’s KeyRemap4MacBook and restart. (As noted in the notes below, you may also need NoEjectDelay and PCKeyboardHack)

Next, install this private.xml with the following command in the Terminal:

curl 'https://raw.github.com/gist/1359957/2e8f2144caeac69134495914639637afbc37d269/private.xml' > \
   "$HOME/Library/Application Support/KeyRemap4MacBook/private.xml"

Warning: This command will overwrite any existing private.xml settings you may have. This is probably okay.

Third, open the KeyRemap4MacBook preference pane, click ‘Reload XML’, and check the new “Change top row to 'all function keys'” checkbox.

You’re done! Enjoy your new extra function keys, and having gotten rid of those useless extra [esc] and [⏏] keys!

Notes

  • Currently, [F18] and [F19] are just F18 and F19 again (which [F16] and [F17] also are), because the developer hasn’t gotten back to me yet about access to KeyCode::F20 and KeyCode::F21 definitions in his format

  • You’ll really want to install NoEjectDelay, since we’re remapping the
    [⏏] key

  • We’re changing the eject key, so you’ll probably want to enable the “Eject” menu item with the following command:

    open '/System/Library/CoreServices/Menu Extras/Eject.menu'
    
  • We’re stomping on [esc] as well, which implies you’ll want to map something else more nearby to Escape (i.e., as a vimmer, I use Escape quite a lot, so I remapped [caps lock] to Escape using PCKeyboardHack)

    If you wish to do as I did and remap [caps lock] to replace Escape, then you’ll need to be aware of the following:

    • you have to set PCKeyboardHack to remap [caps lock] to keycode 110,
    • you must enable the “Application Key to Escape” setting (don’t ask.) in KeyRemap4MacBook
    • you need to tell OS X itself to ignore the [caps lock] key, under the “Modifier Keys…” panel in the Keyboard system preference pane (select “No Action” for the Caps Lock key)

@puttin
Copy link

puttin commented Nov 14, 2013

Hi!
Can you get the F20 and F21 code with EventViewer?
According to https://groups.google.com/forum/#!msg/keyremap4macbook/hykimXXonLw/RPvh4s1lYbcJ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment