Remap "Ctrl + Up" to 5 "Up" and "Ctrl + Down" to 5 "Down" s

While Ctrl + Left / Right is usually displayed to move the cursor one word to the left / right, Ctrl + Up / Down is usually not mapped to anything in Linux applications. In a similar vein, I want to reassign Ctrl + Up / Down to 5 repetitions of Up / Down keys. Is there a way to do this with xmodmap

or using XKB config? I've done some really custom stuff with XKB (my right Alt is Overlay2), but I don't know where to start sending multiple events / multiple keys for a single event / key.

As a workaround, I can do this in vim:

(n/i/v)map <C-Up> <Up><Up><Up><Up><Up>
(n/i/v)map <C-Down> <Down><Down><Down><Down><Down>

      

However, getting this to work in gedit and eclipse would have been a good enough solution for me. Any ideas?

+3


source to share


2 answers


You can use xbindkeys

for this. You will need to write .xbindkeysrc

and run xbindkeys from your X session (you can use either .xinitrc

, .xsession

or your appropriate option in your DM / WM, if any). You will need something to send keys to X programs. I used xte

from a package xautomation

, but you can also use something like xmacro

(example here ).

In yours, .xbindkeysrc

you write something like this:



"xte 'keyup Control_L' 'keyup Control_R' 'key Up' 'key Up' 'key Up' 'key Up' 'key Up'"
     Control + Up

      

same for Control + Down

(requires line in example). This will undo the control keys (important if you don't want to end up endless) and then press 5 times.

+5


source


Building on Trubert's answer, I ended up with the .xbindkeysrc

following:

"xte 'keyup Control_L' 'keyup Control_R' 'key Up' 'key Up' 'key Up' 'key Up' 'key Up' 'key Up' 'keydown Control_L'"
    Control + Up
"xte 'keyup Control_L' 'keyup Control_R' 'key Down' 'key Down' 'key Down' 'key Down' 'key Down' 'key Down' 'keydown Control_L'"
    Control + Down

      

This fixes two things. First, if you hold down the controls, each press of the Up / Down button causes five (not four) lines to move, and also works after the first press (Trudbert's answer was not).



There are two problems. Control_R does not work, and pressing Ctrl + Up will not automatically repeat the key, similar to how pressing the Up button works. I award Trubert with generosity, but at the end of the period.

In the meantime, hopefully someone comes up with an idea on how to fix this. I was thinking of a custom script that keeps repeating 5 Up until a release event occurs.

+1


source







All Articles