I want to emulate horizontal scrolling when I use my (vertical) scroll wheel and pressing Shift.

In some applications (Chrom{e,ium}) this already works, but I'm looking for a generic solution for X applications.

The closest I got so far is xbindkeys + xdotool.

# ~/.xbindkeysrc
"xdotool click 6"
  shift + b:4

"xdotool click 7"
  shift + b:5

The Problem is that xbindkeys seems to miss some events, and occasionally a vertical scroll "gets through". This is very annoying. It looks like xbindkeys is using some kind of polling?

Also I don't like spawning hundreds of shell commands per seconds.

I got a small screen and have to scroll horizontally a lot.

How can I achieve generic horizontal scrolling?


There is another way that does mostly what I want with xbindkeys and xmodmap.

"xmodmap -e 'pointer = 1 2 3 6 7 4 5 8 9 10'"
"xmodmap -e 'pointer = default'"
  release + shift + c:50

When Shift is held, the pointer buttons 4 and 5 are mapped to 6 and 7. (Buttons 4/5 are fore vertical scrolling and 6/7 for horizontal scrolling). c:50 is the left Shift key. On key release the default pointer mapping is restored.

This solves the "too many events" Problem nicely. However, the Shift key doesn't work as normal modifier anymore. I tried to re-issue the Shift press/release events with xdotool like this:

"xmodmap -e 'pointer = 1 2 3 6 7 4 5 8 9 10';  xdotool keydown Shift_L"
"xmodmap -e 'pointer = default';  xdotool keyup Shift_L"
  release + shift + c:50

According to xev the Shift events get through, but I think it's not recognized as a modifier any more. For example, pressing Shift+A wouldn't produce an uppercase A.

  • 1
    You can also do horizontal scrolling with Ctrl+Arrows for many programs.
    – terdon
    Commented Jan 28, 2014 at 21:24
  • 2
    Thanks, but this doesn't work for me in Firefox. I'm looking for a "generic" Solution that works everywhere. Commented Jan 29, 2014 at 7:26
  • Would it be a problem to run something as root, e.g. using sudo?
    – brm
    Commented Feb 1, 2014 at 13:45
  • It's not optimal to have to sudo. I assume you mean sudo-ing everytime Shift is pressed? Could you elaborate what you have in mind? Commented Feb 3, 2014 at 10:10
  • This might be pointless, but once upon a time this worked for me in ~/.xbindkeysrc.scm. At some point it failed, but it might work on your system.
    – Sparhawk
    Commented Aug 20, 2014 at 15:22

3 Answers 3


I found an acceptable solution for me.

I didn't find a way to use Shift or any other key as my modifier to rotate the wheel axis as long as it is pressed.

I'm now using a simple .xbindkeysrc with a toggle button:

  alt + x

The toggle.sh script looks like this:

  xmodmap -e 'pointer = 1 2 3 6 7 4 5 8 9 10'

  xmodmap -e 'pointer = default'

if xmodmap -pp | grep -q '4.*6'; then

This allows me to toggle the behaviour. When I press Alt + X, my mouse wheel axis is rotated, and when I press it again, it's set to the default.

That should work for now.

If someone finds a way to do it with Shift as a "modifier" (mouse axis rotate as long as it's pressed), please let me know.

EDIT: As Alt+x is a commonly used hotkey, I changed it to:

(xbindkey '(control "b:3") "toggle-wheel.sh")

(I switched to guile configuration so the above should be in a file named .xbindkeysrc.scm)

This will toggle the scroll wheel direction with Ctrl + right mouse button.


You could use btnx and it's gui config tool.

More recent Ubuntu package and here

After you do the button detection on your mouse using btnx-config just map "Scroll Up" along with a shift button modifier to whatever x button pressing you would like.

  • Thanks, I'm having a problem getting it to build on fedora though. Commented Feb 3, 2014 at 19:10
  • 1
    I found a rpm package for btnx now. I don't find a way to map a modifier as a source event (i.e. Shift+WheelUp). I only can map from WheelUp to Shift+some other key. Am I missing something? I also tried to "detect" Shift+WheelUp in the first place, but it said "Button already mapped". The rawcode was 0x02010008 for both cases (Shift pressed and not pressed). I don't think btnx can handle multiple input devices at all (Mouse+Keyboard) Commented Feb 3, 2014 at 19:41

As hinted here, I installed imwheel, then created ~/.imwheelrc with the following content.

Shift_L, Up, Left
Shift_L, Down, Right

I then ran imwheel -b 45 in the terminal. I tested, and I haven't noticed the diagonal problems associated with high scrolling and xbindkeys.

N.B. -b 45 restricts imwheel to capture only up and down scrolling, preventing it from blocking (e.g.) xbindkeys bindings for thumb buttons.


However, there are several problems associated with this.

  • It's inconsistent. I could get it to work with Firefox and Gwenview out of the box, but Inkscape and GIMP didn't work. I could use window matching to not match Inkscape/GIMP, but there should be some way to have it work universally.
  • Even worse, it prevents some other default events, like Ctrl+Scroll wheel, which is normally used to zoom. I tried putting things like Control_L, Up, Control_L|Up in ~/.imwheelrc, but this didn't work.
  • imwheel sends horizontal scroll wheel events to the active window, not the window under the mouse cursor. This is counter to the default behaviour of the scroll wheel. This also suggests that the Ctrl workaround in the point above would also be sub-optimal.
  • imwheel appears to be no longer in development. It's been stuck on the pre-release version for the last 10 years (since 2004).

You must log in to answer this question.

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