I have a mouse with a unusual mapping. I wish to change the right click button from B3 to B2, so far I'm using xbindkeys and I've managed to remap the back and forward buttons, but no luck with right click.

# Forward
"xte 'keydown Alt_L' 'key Right' 'keyup Alt_L'"

"xte 'keydown Alt_L' 'key Left' 'keyup Alt_L'"

I tried variations of Shift + F10 but it didn't work:

"xte 'keydown Shift_L' 'key F10' 'keyup Shift_L'"
  • I don't understand how the keyboard is getting involved here. Do you want a click on the right mouse button to send a middle button event to applications, or something else? Sep 30, 2015 at 22:16
  • Basically the mouse has several buttons, and in the new version they changed the order so I like to set it differently, the reason I am simulating keyboard presses is because I have no idea how to reference the event of "right click" in xkeybinds. What I want is a file that says "map right click to button x, map go back to button y, map go forward to button z". So far I've got the back / forward but if there is a better way please let me know, this is what people suggested online unfortunately (except right click, im experimenting with that). Thanks. Sep 30, 2015 at 23:11

1 Answer 1


If all you want to do is remap mouse buttons, then the easiest way is with xmodmap. For example, to swap buttons 2 and 3:

xmodmap -e 'pointer = 1 3 2'

or put this line

pointer = 1 3 2

in a file called ~/.Xmodmap and run the command xmodmap ~/.Xmodmap when you log in (if your desktop environment doesn't already do that for you).

  • This solved my problem, thanks. I had to use xkeybinds to simulate the back / forward though, for some reason my mouse only has forward on it's keys even though it comes with 5 buttons + the wheel. Any way to assign forward / backwards though xmodmap? I prefer to use 1 file instead of 2 is possible. Oct 1, 2015 at 23:12
  • @Mankind1023 Xmodmap only knows about mouse buttons, it doesn't know about things like “forward” and “backward”. An application may decide to treat a mouse button as a forward command; I suspect it would assign backward/forward to the horizontal wheel, which is buttons 6 and 7 (buttons 4 and 5 are the vertical wheel). Oct 1, 2015 at 23:16

You must log in to answer this question.

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