Terminal application and editors like vim (and emacs I think) make good use of control codes. I.e. Ctrl + M is carriage return and Ctrl + J is line feed. Both of these can be used to insert new lines in vim, or execute commands in shell. They are considerably more comfortable to press than return on basically all keyboards (when Ctrl is remapped to Caps lock at least).

On GUI applications that does not work, and it is annoying as hell. I use Opera as my browser and I tried configuring some support for that, but it only works in some elements. Of course it does not work in other applications.

Does anyone know how to make 'control code' bindings in X to make them act as special characters?
(Ctrl + H for backspace is also very very cool)

  • No, it really does not seem like that besides I knew about xmodmap. It seems to have no way of doing anything with key combinations (except some) and ctrl-m is a key combination. Exception are level choosers - shift and third level chooser. – morphles Jul 25 '12 at 6:12
  • If you try xev, you'll already notice, that Ctrl+M converts into 0A byte. It is called en.wikipedia.org/wiki/Caret_notation and the logic is very simple: to get printable character of control code, just revert 7th bit in the ascii code. Hence, you can't affect it, since there is no mapping table. But your problem is that GUI applications ignore ASCII control codes, or they rely on the keycodes directly, not on a result of XLookupString – Kukunin Sep 15 '15 at 6:34

It's possible using xkb. You will have to create a custom keyboard layout and assign Ctrl (Caps Lock) to be your Level 3 shift key (sometimes called AltGr after its default location). Then set the 3rd level for M to the keysym for CR, J to LF, etc.. It's probably also possible to set up Backspace (using the function keysym, not the Unicode code point).

If you use AltGr (right Alt) in your preferred keyboard layout (e.g. for international characters), this will interfere. There reportedly also exists a Level 5 shift independent of AltGr, so set Ctrl/CapsLk as your level 5 shift instead (disclaimer: I haven't tried this).

There are several tutorials for doing this; here's one.

But if you're making your own layout, also consider just remapping keys you find difficult (e.g. if you never use Right Win, remap Enter onto it where your thumb/pinkie can easily access it).

Incidentally, how can CapsLk+key possibly be easier to press than Enter? It's perfectly symmetric between the hands, except you have to simultaneously press another key.

  • Interesting, I'll see the link you posted when I have time. I also had some idea of getting funky with third level chooser, but I expect that it might interfere with normal ctrl behavior. I use right alt as third level chooser, to use my native chars without switching from English layout. On most keyboards enter is at quite the distance to the right and you must move your hand to reach it. While you can reach Caps with moving just a pinky, and then j or m with index finger on the home row = zero hand motion. Same with backspace only more so. – morphles Jul 30 '12 at 7:50
  • I see; you place your right hand to the left of where I do. Updated my answer with a comment about right alt. – Mechanical snail Jul 30 '12 at 8:05

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.