I would like to be able to apply the same custom key bindings and shortcuts I use on my text editors to my entire desktop environment.

I want to basically remap my keyboard system-wide, not just in a specific application window. That is, when I remap alt + j = Down, I want pressing alt + j to be the same as pressing the "down" key, as far as my desktop environment is concerned.

The shortcuts I use are optimised for keeping hands in a natural position close to the home row at all times:

# Note how
# system-wide remapping of *single* keys is possible with xmodmap.
Caps Lock           --> Escape
Escape              --> Caps Lock    # Switch caps lock with
                                     # the more useful escape key.
                                     # As far as *all* applications 
                                     # are concerned, pressing caps lock 
                                     # is actually pressing Escape. 

# However, I've not found a good way do the same for multiple keys:
alt + space         --> Right Arrow
alt + Escape        --> Enter
shift + alt + h     --> Backspace
alt + x             --> Delete
shift + alt + l     --> Delete

ctrl + alt          --> Alt           # Default alt functionalities 
                                      # remapped to ctrl + alt

In my text editor, this has done wonders for my accuracy, speed, and has helped me tremendously with tendon pains I was having, since my hands now barely need to leave their natural resting position.

First almost-successful attempt at a solution:

Using xbindkeys to call up xvkbd (x virtual keyboard). This is a sample from my .xbindkeysrc:

# h-j-k-l Movement
    "xvkbd -xsendevent -text "\[Down]""
        alt + j

    "xvkbd -xsendevent -text "\[Up]""
        alt + k

    "xvkbd -xsendevent -text "\[Left]""
        alt + h

    "xvkbd -xsendevent -text "\[Right]""
        alt + l


The alt key is usually the default key for calling the menu of an application (for example, alt + F brings up the *F*ile dropdown menu in most applications).

Also, this seems to work with some applications, while others seem to ignore it.

xbindkeys isn't really remapping the keyboard, it's just telling xvkbd to send a signal, which can sometimes create conflicts with the active application (unlike xmodmap, which truly remaps the keyboard).


A system-wide remapping of my keyboard, implemented in a way that is easily portable (an rc file or something similar).

alt is the optimal key of choice, since ctrl is heavily used across applications, and the mod key is taken up by my windows manager (Xmonad).

My setup

I'm running Ubuntu 12.10, with the Xmonad desktop environment.

Is this doable? I don't yet know much about OS-level stuff and how it processes input.

1 Answer 1


The only chance I see is configuring xkb to map your keys accordingly. A few applications like games might directly listen to the actual keys pressed, but usually everything else uses just the xkb mapping.

There are two different tools for configuring: setxkbmap and xmodmap. In theory xmodmap is deprecated and should be replaced by setxkbmap, but sometimes good old xmodmap is handy, too.

You are limited to the features supplied by xkb, but even xmodmap supplies a limited set of modifiers. You can specify four keysyms for each key. To quote it's man page:

The first keysym is used when
no modifier key is pressed in conjunction with  this  key,  the
second  with  Shift, the third when the Mode_switch key is used
with this key and the fourth  when  both  the  Mode_switch  and
Shift keys are used.

Maybe it is a good idea to read more on the details of the system. I would suggest to read here or here to see what is possible.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.