Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I realize arrow key remapping is an old problem, however I cannot seem to find a good solution that lets me select text with SHIFT + remapped keys as I would do with the vanilla arrow keys.

For instance, if I remap Caps Lock to ISO_Level3_Shift and set xkb_symbols to read either

key <AC08>  { [         k,          K , Down, Down] };

or

key <AC08>  { type="THREE_LEVEL",
              [         k,          K , Down ]  };

Pressing Shift+CapsLock+K will behave exactly as CapsLock+K (while Shift+Down behaves differently from Down alone).

I had somewhat more success using higher level macro utilities and generating keyboard events (i.e. generate both the shift and the arrow keypresses); hoever that approach has a whole set of different problems - often the UI response to a simulated keypress is different from the "real" keypress, and there are performance problems as well - I can type faster than the thing can handle.

Tl;dr; how can you shift-select using remapped arrow keys under X?

share|improve this question

You can use preserve for that: add to you type-definition (e.g. THREE_LEVEL) the line

preserve[LevelThree+Shift] = Shift;

This tells xkb to preserve the shift modifier when figuring out the appropriate level from your modifier combination in the case of LevelThree + Shift. The shift modifier is passed on for use by the toolkit or the application (see also here: using preserve with types).

Note that this has impact for example on how the application interprets keystroke combinations: if you had defined the above preserve and

key <AC08> { type="THREE_LEVEL", [ k, K, kappa ]  };

and you'd press Ctrl + Shift + LevelThree + <AC08> the application would read it as a key combo Ctrl + Shift + kappa (instead of usually Ctrl + kappa) because the shift modifier gets preserved and is passed on to the application.

share|improve this answer
    
This is what I was looking for, but I'm missing one final piece: is it possible to configure xkb so that one keystroke toggles the shift (or other) keys? What I want to do is is having for example CapsLock+s toggle the shift key, so that I can use Capkslock+jkl to select text. – dgirardi Sep 29 '13 at 6:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .