Fixing the function keys on the Apple Keyboard in Ubuntu

As I mentioned in a previous post, I love the feel of the Apple Keyboard. It’s comfortable, fast, reliable, and looks great to boot.

[EDIT, 2010-07-07: I recommend you check out this page no matter what version of Ubuntu you are on at this point. It has information for most setups.]

There is a fly in the ointment, however, for Hardy Heron, Intrepid Ibex [and now Jaunty Jackelope] users: The prime real estate of the function keys is unavailable without the finger-pain-inducing <fn> + <FUNCTION> key combo. Changes designed to improve functionality for Apple MacBook keyboard users introduced this bug. This was quite frustrating. I had those keys mapped to all sorts of useful life-changing functions.

There is a solution!

[Hardy and Intrepid users:]
Edit /etc/modprobe.d/options, add “options hid pb_fnmode=2″. Then run

1
sudo update-initramfs -u

[Thanks to Marco for the following!]
Or if you are running more than one kernel:

1
sudo update-initramfs -u -k all

Then reboot. After things are back up, the function keys will act as normal, no more pressing <fn>!

For Jaunty Jackelope (9.10) users:
As it turns out, this bug didn’t get fixed for 9.10. What’s worse: the old fix doesn’t work now! Here’s what you need to do to get the function keys as well as the numpad working.

Numpad

  1. Select System -> Preferences -> Keyboard
  2. Go to Layouts
  3. Click “Layout Options” button
  4. Under “Miscellaneous compatibility options”, select “Default numeric keypad keys” and “Numeric keypad keys work as with Mac”

Now you have a numpad back!

Function keys

I found a comment on this page that said the fix for the function keys was:

  • Edit /etc/rc.local
  • Add:
    1
    echo 2 > /sys/module/hid/parameters/pb_fnmode
  • Reboot

This couldn’t work for me, as the directories from hid down didn’t exist on my system. Instead I did:

  • Edit /etc/rc.local
  • Add:
    1
    echo 2 > /sys/module/hid_apple/parameters/fnmode

    before “exit 0″

  • Reboot

Then the function keys worked as normal! [EDIT, 2010-07-07: I realized more later that "normal" was a little too optimistic. For an explanation of what the 2 means in the command above, as well as how to change the behavior easily, see this page.]

Post to Twitter Post to Delicious Post to Digg Post to Reddit

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

This entry was posted in Desktop and tagged , , , . Bookmark the permalink.

21 Responses to Fixing the function keys on the Apple Keyboard in Ubuntu

  1. Philips says:

    Oh! it is great. I was searching for this information from last 3 days.

    Really thanks for the information.

  2. Zac says:

    I have an apple wired aluminium keyboard the small version and the function keys seem to act normal with Ubuntu 8.04, it was simply plug and play ie I don’t need to press fn Fxx to access the function. The control, command (alt) keys are normal. However,I would like the command/option keys to function like they would on a mac. eg command-left arrow = move cursor to beginning of line, etc.

  3. @Zac: Might be a difference between the large and small models. I didn’t have the problem with the larger one once I upgraded to Jaunty.

    As to your other point, I didn’t look for that functionality, since I’m not very familiar with the Mac platform. But that does sound like a useful shortcut, so if you get it working, please share!

  4. sanj says:

    Great work! This bug has been moving all over the place with previous fixes never working in the newer version! You can add this solution to this bug (https://bugs.launchpad.net/ubuntu/+source/linux/+bug/201711) on the Ubuntu launch pad.

  5. @sanj Glad it helped you! I’ve posted the fix to the Launchpad bug, thanks for the suggestion.

  6. Linux rules and I’m getting rid of my Mac G5 but I’m joined at the hip to my Mac keyboard.

    It makes my head hurt to contemplate the vast depths of knowledge that enabled you to know how to figure out this fix but I’m delighted to find that it works!

    Thanks Samuel.

  7. @Alan Actually, I can’t take any credit for it. I ran into the issue, Googled a bit, and found a reliable solution. Thanks must go to the actual arcane wizards who documented the fix.

  8. Olli Halkola says:

    Hi, i patched kernel with http://lkml.indiana.edu/hypermail/linux/kernel/0903.0/01675.html
    and then i found this http://lkml.org/lkml/2009/4/28/287 i hope i get my new a1242 mini keyboard to rock and roll.

  9. Olli Halkola says:

    It worked, now my mini keyboard works. :)

  10. Alex says:

    Hello,

    you lucky people! I wish I understood what to do with the above information!

    I would like to get round the use of the key. Would anyone take the time to explain how to do this to a (competent) noob? Or is there a piece of software that could do it?

    Thanks in advance,

    Alex

  11. @Alex What problems are you having? What version of Ubuntu are you running? If you are on Hardy, Intrepid, or Jaunty (latest three) then the above instructions should serve you well.

  12. Alex says:

    Hello Samuel,

    I’m on Mac 10.4.11. I guess the above advice will not be appropriate to me?

    Thanks anyway :-)

    Alex

  13. @Alex Yeah, not exactly :-) As far as I’ve heard, the keyboard works fine on Macs, as that is what it was designed for.

  14. Alex says:

    @Samuel, turns out its done in the preferences>keyboard and mouse… Told you I was a noob!

    Thanks for your help anyway.

    Toodles

    Alex

  15. akahige says:

    Samuel … just wanted to say thanks for writing this up.

    The second of the options — hid_apple — works perfectly on Ubuntu Karmic.

  16. The last option worked for me (adding echo 2 > /sys/module/hid_apple/parameters/fnmode to /etc/rc.local). Now my aluminum keyboard is working perfectly.

    Thanks!

  17. Elidia Stemm says:

    [..] A bit unrelated, but I absolutely liked this blog post [..]

  18. James says:

    Thanks so much for posting this.

  19. Brooks says:

    Nice! thanks for the post

  20. Marco says:

    Good info.
    Remember if you boot more than one kernel (for example if you have the RT kernels from ubuntustudio and the stock kernels from ubuntu) to actually update every initramfs.

    1
    sudo update-initramfs -u -k all
  21. @Marco Thanks very much! I’ve updated the post with your tip.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>