making keyboard shortcuts in linux as uniform as the mac

Keyboard shortcuts in GNU/Linux are not as uniform as in, say the Macintosh. Having uniform keyboard shortcuts for common tasks which do not conflict is an integral part of a good user interface. While the trinity of cut-copy-paste shortcuts have been almost universally implemented, there are quite a few other shortcuts that should be common (closing a window, quitting an application, opening preferences). Yesterday, I tried to get some uniformity in keyboard shortcuts in my GNOME desktop.

The first thing to do is to allow changing the accelerators (keyboard shortcuts) in the GNOME configuration. This can be done by issuing the following command at a Terminal:
gconftool-2 -t bool -s /desktop/gnome/interface/can_change_accels true

Then I mapped Ctrl to the Alt key (which is just in the place where the Command key is on the Mac) and the Alt key to the Windows key. This can be done in GNOME by going to System »Preferences » Keyboard » Layout » Layout Options… and changing Alt/Win key behaviour. This is not really necessary, but mapping the Ctrl key to the Alt key made it a lot easier for my fingers.

Now to change the keyboard shortcut corresponding to any menu in GNOME, you simply have to select the menu item and press the shortcut you wish to have associated with the menu item. However, this does not work for all GTK programs. The programs for which I could change the shortcuts using this way included Nautilus, Rhythmbox, Pidgin, Totem, Terminal, Gedit, Image Viewer. For example, I changed all the preferences shortcuts to Control+comma. Keep in mind that if the shortcut you assign is already assigned to some other function, then the shortcut will be reassigned to the menu item you’ve selected and the previous functionality corresponding to the shortcut will not have any shortcut assigned to it.

Some other shortcuts that I changed in Nautilus are: Control+I for Properties (this is consistent with the same shortcut for Firefox’s Page Info and the Mac OS X Finder), Control+D for Duplicate, Control+Shift+Delete for Empty Trash and Control+Shift+C for Computer.

Of course, we also have to change the shortcuts for the window manager we’re using. Since I’m using Compiz, I used ccsm (Arch: ccsm, Ubuntu/Debian: compizconfig-settings-manager package), to change the shortcut for closing an window to Control+W (in General Options » Key bindings). Also I changed the default shortcut for Run Command… from Alt+F2 to Control+space in Gnome Compatibility. Since I’d gotten used to pressing Alt+Tab for switching windows, and now Alt had become the Win key, I also had to change the shortcut for switching windows to Control+tab (in Application Switcher).

Firefox: I used the Keyconfig extension to change the keyboard shortcuts in Firefox. I changed the Preferences, Back and Forward shortcuts, as well as the shortcuts for switching to tabs 1 to 9. Since Control+W was now used to close the window, I assigned Control+Shift+W for closing the tab (the same applied for other applications which use tabs a lot, like Gedit).

VLC. I tried to change the shortcut for preferences in VLC to Control+comma but I could not find any way of doing so. There is an option for changing the hotkeys, but that does not include Preferences. So I’ve to stick with the default for the time being. GIMP had a nice shortcut editor, using which I could easily change the shortcut for Preferences.

After all this, you might want to turn off the ability to change accelerators in GNOME by issuing this at the terminal: gconftool-2 -t bool -s /desktop/gnome/interface/can_change_accels false

Update (18 Oct 2009): Registered the uniform-keyboard-shortcuts blueprint in Launchpad.

12 thoughts on “making keyboard shortcuts in linux as uniform as the mac

  1. genius!

    thanks so much. Ive been trying to solve this issue for more than a year! I really think the mac guys nailed the keyboard shortcuts.. lets see how UI-design/programming-design changes after multi-touch “custom(app specific) keyboards” effectively destroy the default qwerty world.

    once again, thanks for this tutorial. will make my time in gnome much easier…

  2. if you change the default shortcut in ccsm to ctrl+q (close window).. this is more like quit application in mac. and in linux, most apps quit when the window is closed right?

    this way, you can close tabs in firefox/gedit/terminal without closing the application!

  3. I also recommend installing gnome-do (default shortcut = `(grave)) since i never use that key… ever.

    + gloobus (but you need to disable gloobus for gtk apps when changing their shortcuts)

    these apps make the interactions with gnome a breeze.

  4. Have any idea how to apply shortcuts on key up, not key down event only?

    This could be usefull, for example on keyboard layout switch.

    If language toggle is mapped on Ctrl+Shift, and at the same time you have any other shortcuts that uses Ctrl+Shift keys, you’ll face some troubles.
    If you have Ctrl+Shift+R shortcut, you are pressing Ctrl, then Shift… argh keyboard layout is switched, and you don’t have R anymore 🙂
    In Windows layout switch is mapped on key release, so language will not be switched until you release both Ctrl and Shift buttons, and you have not pressed any other key at this time.

  5. thanks for the article man, that’s actually my big gripe with using Ubuntu. I will try to tweak my stuff tomorrow…

    Now if only Textmate could get ported to Linux…

  6. i tried redcar… closest i got to textmate.

    I’m trying to get the “monaco” font I use in textmate.. onto linux.. never thought that fonts would matter so much…. but the DO!

  7. I have been reading your blog now for quite some time and really love it. I don’t know if it’s your style or not , but do you think you could perhaps do a post on the oil spill in the gulf?

    I love your thoughts and opinions, and would love to see your commentary on this tragedy.

Leave a reply to rachel@buybikini.org Cancel reply