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.

11 thoughts on “thinkpad keys in firefox

  1. aussiebear says:

    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. :)

  2. Nightwing says:

    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!

  3. wilcham says:

    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.

  4. wilcham says:

    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.

  5. @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);” />

Leave a Reply

Your email address will not be published.

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>