I have the "RightClick" (menu) button on my keyboard, which is completely useless. I want to remap the keyboard such that whenever I press this button, it simulates an "UP ARROW" then after 0.1 second a "DOWN ARROW". In my everyday usage I need to press my up then down arrows repeatedly and I want to simplify this process. Is this in anyways possible?
1 Answers
You should be able to use xte
or xdotool
to do this in combination with xbindkeys
; either xte
or xdotool
are necessary as you need to synthesize two key strokes, which those programs allow you to do.
First, install the programs with:
sudo apt-get install xbindkeys xdotool
Add in your ~/.xbindkeysrc
the following:
"xdotool key --delay 100 Up Down"
c:135
The command in quotes has to come first, followed on the second line by the keycode or keysym that you want to use with it; that is my keycode for the Menu key. You can also try using just the keysym (Menu
) in place of that keycode. If you have problems, use xev
and press your menu key to find your keycode and keysym.
You said you wanted a delay of 0.1 second and xdotool
counts the delay in milliseconds, so 100 ms is a tenth of a second (1000ms=1 second). The two keys required are specified at the end of the command; you can change these to say f g
if you want to test it in terminal to see if you are getting the correct keypresses.
Now run killall xbindkeys
and xbindkeys &
so the configuration file is read (or logout and login again) and pressing the menu key will now do what you want.
You may also want to deactivate one of the presets in ~/.xbindkeysrc
, as that can cause problems. Please see my answer for this question for more on that.
For more information, see man xdotool
, man xbindkeys
or the Ubuntu manpages online.
-
Don't you have to use an extra step to make
xbnidkeys
start when you login or does it somehow do that automatically? – Seth Mar 27 '13 at 02:15 -
xbindkeys
andxdotool
without even remapping the key, as pressing the menu key could be set to trigger thexdotool
action (up/down arrow). – Mar 26 '13 at 23:56