thinkpad keys in firefox

I use a Thinkpad T43, and I love it. Along with other Thinkpads and IBM keyboards, it has a couple little keys above the arrow keys that go “back” and “forward” in your browser. At least, in Windows IE. Shockingly, they don’t work with Firefox (in Linux) out of the box.

Update: Rob Mayoff’s howto, originally for Mozilla, now includes Firefox. He’s done most of the work in a package that you can install with a single click. If you just want your thinkpad keys to work already, follow his howto.

Otherwise, here’s the recipe for Firefox, versions 0.8 through 2.x. (It probably works with earlier and later versions too, but no guarantees.)

First, you need to map the keys to X keysyms. There are in-depth instructions on the linux-thinkpad mailing list, but all you need to do is add these two lines to ~/.Xmodmap:

keycode 234 = F19
keycode 233 = F20

and then reload it:

$ xmodmap ~/.Xmodmap

Now, you need to perform surgery on one of the jar files that Firefox uses to configure itself. In the chrome/ subdirectory of your Firefox directory, unpack the browser.jar file like so:

$ cd firefox/chrome
$ unzip browser.jar

Fire up your favorite text editor and open the content/browser/browser.xul file. In the section, find these lines:

<key id="goBackKb"  keycode="VK_LEFT"
     command="Browser:Back" modifiers="alt"/>
<key id="goForwardKb"  keycode="VK_RIGHT"
     command="Browser:Forward" modifiers="alt"/>

…and add these two lines immediately after them:

<key id="goBackKb"  keycode="VK_F19"
     command="Browser:Back"/>
<key id="goForwardKb"  keycode="VK_F20"
     command="Browser:Forward"/>

Repackage browser.jar, like so:

$ zip -rD0 browser.jar content/browser/

If you weren’t working in your firefox/chrome directory, copy the new browser.jar over the existing one in firefox/chrome.

Restart Firefox, and you should be set! If not, feel free to email me, and I’ll try to help.

See also:

10 Comments

  1. 11/25/2006 #

    thanks to Mike Baas for pointing out some errant slashes left over from the migration from snipsnap to pyblosxom. they’re fixed now.

  2. aussiebear
    5/22/2007 #

    Hi,

    Just want to say a big THANK YOU for your article.

    I can confirm that this works on my IBM ThinkPad R40 using Arch Linux 2007.05 with Firefox 2.0.0.3

    Regards. :)

  3. slackhack
    5/24/2007 #

    works on my R40, too. greatly appreciate.

  4. Nightwing
    6/13/2007 #

    Thanks a lot.  I’ve been trying to install Rob Mayoff’s fix but have been unsuccessful.  However, after a little editing, I’m happily using the keys on my IBM T42 again!

  5. Koen De Jaeger
    10/25/2007 #

    Worked for me on the X61 tablet too.

  6. wilcham
    11/24/2007 #

    I know this is propably not the best place to ask, but maybe someone knows how to (in Firefox running under winxp) reassign the Back and Forward keys to Previous Tab and Next Tab? I tried keyconfig extension but it doesn’t catch the keys. Right now I have assigned Ctrl+Alt+L/R-arrows and it works but the special Thinkpad keys would’ve been more useful to me, because I surf using tabs, and rarely use Back and almost never Forward.

  7. wilcham
    11/24/2007 #

    I know this is propably not the best place to ask, but maybe someone knows how to (in Firefox running under winxp) reassign the Back and Forward keys to Previous Tab and Next Tab? I tried keyconfig extension but it doesn’t catch the keys. Right now I have assigned Ctrl+Alt+L/R-arrows and it works but the special Thinkpad keys would’ve been more useful to me, because I surf using tabs, and rarely use Back and almost never Forward.

  8. 12/27/2007 #

    @Wilcham If you know some Chinese you can get your problem done here

    Just copy the followings to replace the original methord of “assign the Back and Forward keys”:

    <key id=”goBackTabKb” keycode=”VK_F19″ oncommand=”gBrowser.mTabContainer.advanceSelectedTab(-1,true);” />
    <key id=”goForwardTabKb” keycode=”VK_F20″ oncommand=”gBrowser.mTabContainer.advanceSelectedTab(1,true);” />

  9. Sit
    9/25/2008 #

    Skimming through
    http://dev-loki.blogspot.com/2006/04/mapping-unsupported-keys-with-xmodmap.html

    I learned that it would work for me just with:

    keycode 233 = XF86Forward
    keycode 234 = XF86Back

    But thanks anyway for the lead.

  10. tarocchi
    12/20/2008 #

    also i got a t43p, and it s awesome…thank you for this little trick!

Post a Comment

Post a comment...

Your email is never published nor shared.

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>


  • home
    about
    pictures
    software
    index
    feed