Mapping volume and eject keys to 3rd-party keyboard

May 19, '11 07:30:00AM

Contributed by: Balthamos

If you have a keyboard that does not have eject and volume controls natively (like Das Keyboard), you can map them using KeyRemap4MacBook (it works for more than MacBook though!). This is kernel level mapping, so the keys act native, contrary to solutions provided by Quicksilver or Spark.

Download and install KeyRemap4Macbook. Despite the name, it works for any Mac, not just the Macbook.

You can search through the preferences and see if any of the built-ins work for you. I chose to do my mappings manually, as it allows you to map any key to any key.

Open up your private.xml through the "Misc & Uninstall" tab of KeyRemap4Macbook. The following code maps Insert, Home, and Pageup to Volume Down, Up, and Mute respectively. Those keys are pretty useless anyway, so you probably won't miss them. If you wanted to map them to something else, you can do that here. If you want syntax on different keys, you can find them documented here:


Here's the code:

<?xml version="1.0"?>
      <name>Volume Keys</name>
      <appendix>Up, Down, Mute</appendix>
      <autogen>--KeyToConsumer-- KeyCode::PC_INSERT,         ConsumerKeyCode::VOLUME_DOWN</autogen>
      <autogen>--KeyToConsumer-- KeyCode::HOME,              ConsumerKeyCode::VOLUME_UP</autogen>
      <autogen>--KeyToConsumer-- KeyCode::PAGEUP,            ConsumerKeyCode::VOLUME_MUTE</autogen>
I mapped PrintScreen to Eject (which is also available as a built-in option). If you wanted to map a different key to Eject, this is the following syntax.
<autogen>--KeyToConsumer-- KeyCode::PC_PRINTSCREEN, ConsumerKeyCode::EJECT</autogen>
Let me finish by stating that this is very powerful software, and it is capable of much more. For instance, I have it do my Dvorak layout remappings, so to user level programs my keyboard looks like a standard QWERTY. This allows for greater compatibility throughout the system. Often, non-QWERTY layouts got tripped up by Java or Carbon apps. With this program, you should have no issues. If you use a non-standard keyboard layout, look into this program!

[crarko adds: I haven't tested this one.]

Comments (5)

Mac OS X Hints