Mouse-less Firefox

Recently I’ve been trying to use my mouse when browing with Firefox as less as possible. This is largely because the influence from Gnome Do, with which you could use keyboard quite effeciently to finish common tasks.

What I have expected, was to use Emacs-like key bindings to finish basic browser operation, like “forward”, “back”, “jumpe to next/previous tab”, “scroll up/down” etc.

There are quite a few instructions telling you how to change the shortcut keys in all input fields by setting the gtk-key-theme-name to Emacs. While that is nice to know, it is merely the basic step. Most of the operation to the browser itself is still untouched.

Then I came across the Surfkeys extensions which defines a couple of key bindings for common tasks. But currently there are two issues with this extension: one is the key bindings are not easily configurable (The only way is to modify the source code); another problem is the functionalities it provides lacks some essential ones I would like to have (like scroll one line up/down). The best feature of this extensions is that it can bind shortcut keys to the “Next/Previous” link on webpages in order to easy navigate between pages. This binding can be configured to be website specific, which means it is dynamic.

Then someone told me in Surfkeys’ mailing list that there is another Firefox extension called “VIMperator”. The name of it is quite self-descriptive, yes, this one transforms the whole Firefox into a VIM-like program. While it is a very complete solution regarding functionality and shortcut key definitions, it also bring the issue due to which I can not get along with my VIM very well: the double modes style. The VIM is special for its modal style, but you have to hit ESC once in a while and sometimes you even forget in which mode you are in. So I am not a fan of modal editor, nor is a modal browser.

Another problem with VIMperator is some shortcut keys defined by certain websites (like GMail, Google Reader) are not accessible exept you disable the VIMperator temperarily. Even after you diable the VIMperator, the GMail shortcuts doesn’t seem to be as easy to use as before: the webpage always lost focus therefore you have to hit tabs a lot to make the key ‘j’/’k’ functions normally.

After using VIMperator for one day, I gave it up. Then I was luckiy enough to find another extension “Keyconfig”. It actually provides barely only one single functionality which is to customize all of the key bindings of Firefox, of its extensions and more importantly of any self-defined functions.

With this extension, it becomes very easy to fulfill my need to have Ctrl-N/Ctrl-P mapped to “Scroll one line Up/Down”. I borrowed some scripts from Mozilla’s knowledge base, andd bind new keys with these scripts:

  • Scroll Line Down (bind to Ctrl-N)

  • Scroll Line Up (bind to Ctrl-P)

  • Scroll to the Top (bind to Alt-<)

  • Scroll to the Bottom (bind to Alt->)

  • Switch to Next Tab (bind to Alt-F)

  • Switch to Previous Tab (bind to Alt-B)


I also changed the key bindings of some existing functionalities like “Forward”, “Back”, “Scroll Page Down”, “Scroll Page Down” and “Search” to Ctrl-F, Ctrl-B, Ctrl-V, Alt-V and Ctrl-S repectively.

One trick to make all these possible is to disable the “Menu Access Key” which is “Alt”, otherwise those key bindings with Alt may trigger certain menu item. To do this, search “ui.key.menuAccessKey” in “about:config” page and change its value to “0”.

Also it is worth to mention that the mapping I am using overlaps with some default key bindings of Firefox. E.g. Ctrl-S and Ctrl-P are by default binded to “Save As” dialog and “Print” dialog. You have to either disable the shortcut keys of these functions or change them to something else.

I think Keyconfig provides a lot of possibilities to experiment with new scripts, which would change the behavior of Firefox even more. I haven’t got time to play with other self-written scripts, and have no idea if that would be possible and how powerful it would be. So i may share any new tricks in the future as long as I’ve successfully got them work.

At last, there is one thing I am missing in Keyconfig is the ability to have consecutive key bindings like in Emacs. (E.g. Ctrl-X Ctrl-S to Save) But seems there is another Firefox-based Emacs-like browser “Conkeror” which, like the VIMperator, completely changes the browser into something quite Emacsen. I probably will try it soon and if that comes better than defining/modifying key bindings by yourself via Keyconfig, I will post my feed back here.


About this entry