How to make Control-j works as Return without Control bit set(!) using xkb [and|or] xmodmap

keyboard shortcutskeyboard-layoutxkbxmodmap

It looks like extremely convenient for me to use Control-j instead of Return in xterm and vim, and I want to use this sequence for all X apps.

It can be easily done using xkb by remapping ISO_Level5_Shift to the Control key, and setting Return as a 5th level symbol for j key, but after this all other Control combinations in vim and xterm stop to work (because xterm and vim can't understand Mod keys), and this is absolutely unacceptable.

I've managed to do this without remapping ISO_Level5_Shift by using "LOCAL_EIGHT_LEVEL" key type in the xkb_symbols section, which uses Control (instead of ISO_Level5_Shift) as a Level5 modifier:

    key <AC07> { [ j, J, plusminus, NoSymbol, Return ], type[Group1]= "LOCAL_EIGHT_LEVEL" };

The problem of this solution – xkb sets Control bit, and Control-j returns Control-Return instead of just Return. Sometimes (quite often, btw) this combination doesn't work as Return.

So, what I need is to modify one of these solutions to unset Control bit for Control-j combinations.

According to this link: Arch Wiki article about XKB it can be done, but I don't know how to do this. So, that's my question.

Maybe I have to add some xkb_compatibility rule for Return+Control, or something like this, or add some xmodmap mappings – any solutions would be appreciated.

Best Answer

I've found solution for my question. You can assign an action for each key inside xkb_symbols section. Redirect is an action we need:

key <AC07> { [ j,    J,     plusminus,      NoSymbol,      NoSymbol ],
  type[Group1]="EIGHT_LEVEL_SEMIALPHABETIC",
  actions = [ NoAction(), NoAction(), NoAction(), NoAction(), 
                                Redirect(key=<RTRN>, clearmods=all) ]
};

Using this action you can clear existing modifiers or add new.

Related Question