Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a Logitech MX400 Laser Mouse which has 5 buttons + 4 for vertical/horizontal scrolling. I would like it set up so instead of horizontal scrolling pressing right on the scrollwheel will send Ctrl+Tab and left will send Ctrl+Shift+Tab, which will allow me to cycle through tabs in browsers.

Also, it would be nice if I could remap the middle button to one of the ones on the side as it is really hard to press down.

Another bonus would be if I could write a script that allows me to define what buttons do what dependent on which window is currently active.

I have tried using xmodmap but I could only see how to rearrange buttons, not have them send key signals.

Thanks in advance.

Button Map (using xev):

Left        1
Middle      2
Right       3
ScrollUp    4
ScrollDown  5
ScrollLeft  6
ScrollRight 7
Backward    8
Forward     9
share|improve this question
up vote 9 down vote accepted

The xbindkeys and xte can help you.

For example my .xbindkeysrc file looks like this:

# close the window under the mouse cursor
"xte 'mouseclick 1' && xte 'keydown Alt_L' 'key F4' 'keyup Alt_L'"

# double click
"xte 'mouseclick 1' 'mouseclick 1'"
share|improve this answer
This is fantastic and extensible, many many thanks – Callum Rogers Oct 23 '10 at 14:11
Works like a charm, thanks. – aviraldg Jan 18 '11 at 10:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.