Feed Sign in with OpenID OpenID

Simon Willison’s Weblog

OS X Tip: Remapping keyboard shortcuts

On my Mac, Apple+W is the shortcut for closing a window (or tab in a tabbed application such as Safari or Firefox) while Apple+Q quits the application completely. These keys are right next to each other on the keyboard. Today, for the final time, I hit the wrong key and accidentally sent a couple of days accumulation of useful browser windows straight in to the abyss. I say for the last time because my intended IRC rant about the stupidity of setting those two keys right next to each other was cut off by Richard Soderberg, who showed me how to remap keyboard shortcuts for any application in OS X.

  1. Bring up the Keyboard & Mouse preference pane.
  2. Hit the Keyboard Shortcuts tab.
  3. Click the + icon.
  4. Select Firefox from the Application menu.
  5. In the Menu Title box, enter the exact text “Quit Firefox”.
  6. In the Keyboard Shortcut box, enter a new shortcut (crysflame suggested Option-Apple-Q).
  7. Click Add.

You’ll need to restart Firefox to see the change, but sure enough the old keyboard shortcut has been replaced—and the menu has even been updated to reflect the change! Magic. I’d be interested to know what happens when you try this in apps that have more than one menu item with the same name. Right now I’m going through all my other multi-window apps (SubEthaEdit, Safari etc.) and remapping their quit keys as well.

This is OS X Tip: Remapping keyboard shortcuts by Simon Willison, posted on 8th June 2004.

View blog reactions

Next: Backporting from Python 2.3 to Python 2.2

Previous: They Work For You

16 comments

  1. you could probably programatically accomplish this for the other apps you want. the keymapping is written to .GlobalPreferences.plist like:
            <key>NSUserKeyEquivalents</key>
            <dict>
                    <key>Quit Safari</key>
                    <string>@~Q</string>
            </dict>
    
    it looks like the string will always be "Quit $app_name", so given a list of the app names you could use plistlib to add the other key/string pairs to the plist file.

    rayg - 8th June 2004 05:21 - #

  2. For Mozilla users, the Multizilla extension gives you the option to be warned when closing a window with more then one tab open. I was glad to find this out after one too many—no, far too many—experiences like yours.

    Micah - 8th June 2004 06:06 - #

  3. For me this is only really a problem with a tabbed browser, as I don't close windows/tabs as much, or have anywhere near as many open windows/tabs, in other applications. I wonder why the browser doesn't remember all the tabs/windows you had open when you last quit, then redisplay them from cache when you start the program again. It seems like it'd be easy to do, and it would make this problem far less annoying.

    oli - 8th June 2004 06:31 - #

  4. I don't think my frustration level has hit as high as yours yet, Si, but I feel your pain. A number of times I've had to wade through the history panel (which is really annoying because you can't open all in tabs) trying to find things I've lost when the Windows restart randomly feature rears its ugly head :-\

    oli, that would be bloody fantastic. Someone told me once there is a Firefox extension to do that -- but I haven't got around to finding it either.

    Meri - 8th June 2004 07:52 - #

  5. If you use Mozilla/Firefox there is an indispensable plugin that will remember the opened tabs even if you close the browser or if it crashes. Its called Session Saver and can be found here. I cannot live without it anymore.

    Nick - 8th June 2004 11:49 - #

  6. Nick, yep, me too.

    My only beef with SessionSaver is that it works a bit too quietly; it saves the session from the last window closed, so that if you close your tabbed window before a separate one (a popup, or a link opened in a separate window), you're stuck with a "session" consisting of the last window closed.

    ...Perhaps the warning extension will do to avoid that.

    Jeremy Dunck - 8th June 2004 16:28 - #

  7. Just back from trying TabWarning. Seemed like it'd be dandy.

    Don't use it; it apparently conflicts with Session Saver, such that you get a handy warning, and then don't have a saved session when you next start. Not much help there...

    On a related note, this sort of geeky extension cobbling and incompatibility worry probably results in extensions being used a lot less by the mainstream.

    Jeremy Dunck - 8th June 2004 16:35 - #

  8. I don't think your real problem is that the W and Q keys are so close together. Your real problem is that you have applications which will closed windows in an unsaved state.

    Now, if you try and close a Word document with typed-but-unsaved changes, it'll ask you for confirmation. It's easy to understand that the document is "dirty", because the changes are obvious. It's not so obvious what constitutes a "dirty" state for read-only (-mostly) documents, like a web browser window.

    I think Mozilla (at least 1.7) does a fairly nice job of asking me if I really want to quit with X number of tabs open. Firefox really ought to do this, as a built-in feature. The only thing better is the always-saved nature of Workspaces in OmniWeb 5 (apparently similar effects can be accomplished with various Mozilla and Firefox plug-ins).

    Applications that behave well is a better solution, IMHO, than manually changing your keyboard shortcuts to something that (a) no one else will be able to use (not necessarily bad), and (b) you will only be able to use on your own machine(s), and (c) is a pain in the ass to configure.

    Alderete - 8th June 2004 17:12 - #

  9. For what it's worth, I've been using a Firefox pre-0.9 nightly, and it now pops up a warning dialog when attempting to close the browser with multiple open tabs.

    jacob - 8th June 2004 18:14 - #

  10. I have been using Tabbrowser extensions and have found the "undo close tab" feature really good.

    david - 8th June 2004 20:20 - #

  11. Where on IRC do you hang out? I have been struggling to find channels worth the time.

    eLephant - 9th June 2004 06:58 - #

  12. It looks like this isn't availible in 10.2

    David Robarts - 9th June 2004 07:15 - #

  13. Wow! What a great tip! The Windows version of Firefox seems to have disabled the instant close on Ctrl-Q, so I haven't had the problem lately, but I used to always accidently close the whole browser with typically 50+ tabs. And it seemed that I did this more on my Mac than my PC. Never again. :D

    Scott Johnson - 9th June 2004 07:16 - #

  14. eLephant: I usually only go on IRC a few times a week, but when I do I tend to hang out on FreeNode in the #wordpress and #joiito channels. The #python channel is great for quick Python questions as well.

    Simon Willison - 9th June 2004 08:23 - #

  15. I feel your pain. I am to the point of trying to fix this for 'every application' I use. My hope is to find a program that will automaticaly remap the keyboard on a per-application basis. This would let me define keyboard behavior for every application - without trying to figure out how any particular application allows change of keys.

    Steve - 3rd September 2005 05:16 - #

  16. "Wow! What a great tip! The Windows version of Firefox seems to have disabled the instant close on Ctrl-Q, so I haven't had the problem lately, but I used to always accidently close the whole browser with typically 50+ tabs. And it seemed that I did this more on my Mac than my PC. Never again. :D " Right! I like Wow.

    wow-gold - 5th September 2005 10:32 - #

Comments are closed.

Previously hosted at http://simon.incutio.com/archive/2004/06/08/remappingShortcuts

A django site