Hacking a 100% zoom feature onto NoSquint with KeyConfig

I recently blogged about the NoSquint Firefox extension, for remembering per-site text zoom levels. I also recently blogged about the Keyconfig extension, which allows you to change hotkey bindings. I guess you could say that this post is the bastard child of those two posts.

The one feature I've been wanting from NoSquint is a keyboard hotkey that jumps the zoom level straight to 100%. I keep my default zoom level at 160%, but many sites just don't render well at that level. A few are downright unusable. I can hit Ctrl-dash a few times to dial down the zoom on those sites, but I really wanted a way to easily jump right to 100% (the standard Ctrl-0 Firefox hotkey jumps to the default zoom, not to 100%, when running NoSquint).  I submitted an enhancement request to the extensions author, but this morning I realized that I could probably just add the hotkey myself. I was browsing the NoSquint source when I struck on the idea to use Keyconfig to create the binding, rather than mess around with unpacking, changing, and repackaging the source JAR file. 

Here's how you do it. Bring up the Keyconfig configuration UI (Tools/KeyConfig). Click the "Add a new key" button. Give the hotkey a name (I used "Zoom to 100%"), and in the big textbox enter:

NoSquint.zoom(gBrowser.selectedBrowser, 100);

Save the hotkey definition, and bind it to the hotkey of your choice (I used Ctrl-Alt-0).

That's it. Now when I hit Ctrl-Alt-0, my zoom level jumps right to 100%. Perfecto.

 UPDATE -  the original version of the hotkey code didn't remember the 100% setting. I've updated it so it does.


Comments have been disabled for this content.