I have really gotten used to the "Simultaneous Vi Mode" functionality of KeyRemap4MacBook which lets you press and hold the s and d keys simultaneously and then use the h, j, k, and l keys as the arrow keys. When s and d are pressed together, no s or d event is fired, but when I type normally I don't notice any delay problems with hitting s or d individually.

How could I recreate this functionality in Linux (specifically RHEL 6.4)?

A couple ideas I had:

  1. If s+d could be remapped to a modifier, then the keys h,j,k,l+modifier could be mapped accordingly. (The keyboard I am using now does not have any spare modifier keys available to use instead of s+d, plus the point of Simultaneous Vi Mode is to keep all fingers on the home row. CapsLock is already remapped to Control and Escape).

  2. Ideally, I would find a way to do this using system settings or something like XKB keyboard which I am using already. If that's not possible, perhaps something similar to the xcape program (which I am using and which lets keys be mapped to different keypress and modifier key symbols) could be written. xcape triggers off of key release though, so it would have to be tweaked to keep the s and d keys from being too slow.

  • On RHEL 6.4? Are you using vim from X or via terminal? – Otheus Apr 24 '15 at 9:54
  • Oh, and how do you map CapsLock to Control AND Escape?? – Otheus Apr 24 '15 at 9:55
  • Map CapsLock to Control and then use xcape (linked above) to map short presses of control to Escape. In the question, I refer to a Vi-like mode of KeyRemap4MacBook, not to vim itself. So far the most promising option I found for what I am looking for is to use the Python Xlib module in a way similar to that used by Plover. So far, I haven't had much time to work on this. – ws_e_c421 Apr 25 '15 at 19:21

You can't do this with the standard tools, you would have to write something (probably a lot of the xserver will be affected, and if you want this to work outside X, there will be kernel changes).

The reason for this is that the ideas the design is based on (and optimized for) does not include chording of regular keys or emitting characters from modifiers.

  • I am still looking into this (need more time). I found the Plover project which seemed to provide a template for an X-based solution, but I want to switch to Wayland so I stopped looking into that. Recently, I discovered caps2esc which uses libevdev and libudev to grab and remap devices dynamically. I think an approach like this could work for chording in addition to remapping but it needs to be investigated further (I'd also prefer a libinput solution). – ws_e_c421 May 3 '17 at 14:25
  • My libinput comment was misinformed. I thought caps2esc worked with the xf86-input-evdev driver which is an alternative to libinput, but it actually works at the libevdev level which is a lower level library used by both projects. The tooling for caps2esc has been refactored into the interception tools project. I believe a well written plugin for interception tools could provide the feature I described. It is on my list to investigate. – ws_e_c421 Oct 28 '17 at 12:54

So after four years, I finally have a rough draft of an answer to this question. The answer is to use Interception Tools which uses libevdev to grab keyboard input and do processing on it before re-emitting it. Regarding simultaneous key mapping, I have made a rough plugin for Interception Tools called Chorded Keymap that lets h, j, k, l act like the arrow keys when s and d are pressed simultaneously.


You would need to get a programmable adapter that sits between your keyboard and computer. They're out there but hard to find.

Or go a tad further, for example: https://www.youtube.com/watch?v=ixbVd8rn6-8

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.