Skip to content

OSX-style keyboard shortcuts for Firefox on PC


Every day, a certain developer comes in to work, sets a Mac & a PC together, fires up Synergy, and shares a single keyboard and mouse for both machines.  This is good.

Every day, this developer tries to use Mac keyboard shortcuts in Linux, and Linux shortcuts on the Mac.  This is not good.  This is frustrating, and distracting, and that is bad!

Fortunately, Firefox provides a way to switch the function of the Control and Alt (Cmd) keys, even though it is not immediately apparent.  In the address bar, type in “about:config” (no quotes.) Firefox will now try to warn you that if you’re not careful, you could really bollocks things up.  That’s ok.  We love to break stuff, then struggle for hours to fix it!  It’s what we do.  So, let’s tell Firefox to cut the scare tactics, go ahead and click the button to accept the warning – fully prepared to take our licks should something go horribly awry.

Now, in the “Filter” bar near the top of the subsequent page (which lists all kinds of great configuration options) type “accelkey” which is most likely set to 17.  17?  Really?  What the heck is 17, here?  Well, if we look at /usr/lib/xulrunner-[your version here]/greprefs/all.js, we get a succinct little explanation:

// Modifier key prefs: default to Windows settings,
// menu access key = alt, accelerator key = control.
// Use 17 for Ctrl, 18 for Alt, 224 for Meta, 0 for none. Mac settings in macprefs.js
// pref("ui.key.accelKey", 17);
// pref("ui.key.menuAccessKey", 18);
// pref("ui.key.generalAccessKey", -1);

Now, if we’re thinking “oh, I can just change this one JS file and be good to go…” banish the thought. It doesn’t work, skippy. Been there, done that, and there’s no joy down that road. Now, it may very well be that somewhere in some file in /usr/lib/firefox… contains this settings, but here, the following command yields no result;

$ grep -r 'accelKey' ./

which indicates that this change is not as simple as editing a file. There is, however, a method which is just as easy.

In your address bar, type about:config and click the “I’ll be careful, I promise” button. Whether or not you want to see future warnings about the multitude of terrifying things lurking behind that URI, well, that’s completely at your discretion. Here, the motto has historically been “Damn the torpedoes… but first, make a backup!”

Whoa! WTF? Actually, if you’re reading this there’s a good chance you’ve already begun your journey down this rabbit hole. But, just in case, let’s spend a minute identifying just what it is we’re looking at here.

It’s a great big set of ‘under the hood’ configuration parameters, presented as simple key/value pairs, with metadata indicating the datatype of the value, and how the current value was set (default, or set by you, the user.)

If that last sentence was totally unintelligible and you just want to swap your keys, have no fear. Here’s how. In the ‘Filter’ input bar (above the column headers, below the address bar) type ‘ui.key’ and the options available to you should be winnowed down to approximately seven lines.

If you’ll recall from the code we saw earlier that came out of that xulrunner preferences file, in Mozilla applications, Command is represented by the integer value 17, and Alt is represented by the integer value 18. So, by that logic, if we swap the values for the ‘accelKey’ (the modifier that you use for the shortcuts to open and close tabs, etc…) and the ‘menuAccessKey’ which is used for accessing the menus and so on. Now Alt+T, Alt+W, Alt+Q are used for opening and closing tabs and windows. Progress, but it’s still not just like on a Mac.

For starters, there is no ‘menuAccessKey’ on the Mac. So, let’s disable it by changing the value to 0.

Based on, we see that Mac actually uses Control as the ‘generalAccessKey’ which plays double duty as the ‘chromeAccessKey’ and the ‘contentAccessKey’ so, should we change the settings? Yes, but not exactly like the Mac. Using a ‘generalAccessKey’ sort of screws things up when using Readline/Emacs style keys for moving around text (eg Ctrl+A, Ctrl+E.) So, set ‘chromeAccessKey’ and ‘contentAccessKey’ to -1, and ‘generalAccessKey’ to -1, and now it feels like OSX!

For more information about the about:config settings, check out and

Good luck, and happy hacking!

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: