1

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?

IVY
  • 11
  • http://askubuntu.com/a/24930/41387 – japzone Mar 26 '13 at 23:28
  • 1
    @EliahKagan Yes that key can be remapped, but I'm not sure this is a duplicate, as the request is not just about a simple remap, but something more specific (up arrow and then down arrow) which could be achieved using xbindkeys and xdotool without even remapping the key, as pressing the menu key could be set to trigger the xdotool action (up/down arrow). –  Mar 26 '13 at 23:56

1 Answers1

1

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.