I use xbindkeys, and I want to map some of my keypad keys to be mouse buttons. I don't want to use mouse keys, because the layout doesn't work for my typing. Currently I do something like this:

"echo ButtonPress 1 | xmacroplay :0"

"echo ButtonRelease 1 | xmacroplay :0"
    release + KP_Insert

And then I turn off key repeat for KP_Insert (keycode 90 on my setup) with:

xset -r 90

Unfortunately it seems that xmacroplay buttons run by xbindkeys don't seem to be picked up by the window manager, so it can't be used to do things like resize windows.

I'm open to other options for mapping keyboard keys to mouse buttons, but using the mouse keys feature not only takes over the entire numeric keypad, but it doesn't seem to allow changing which keys are the buttons, and on my system I can only get button 3 from any of the keypad presses.

1 Answer 1


Ah - the problem wasn't with some sort of privilege level to get the window manager to access the keys. The problem was that I was using modifiers, like "alt + Button1" to move windows.

And when I was doing "alt" + the key I had assigned to mouse button 1 (in the above example "KP_Insert") I was now doing a different key combination and xbindkeys wasn't recognizing the mapping.

So the solution is (using KP_Insert which is keycode 90 on my keyboard):

1) Turn off key repeat for the specific key you want to turn into a mouse button: % xset -r 90

2) Add a binding for the mouse button to .xbindkeysrc:

"echo ButtonPress 1 | xmacroplay :0"

"echo ButtonRelease 1 | xmacroplay :0"
  release + KP_Insert

3) Add bindings for any modifiers + mouse button you might want to use, ex "Alt":

"echo KeyStrPress Alt_L | xmacroplay :0 ; echo ButtonPress 1 | xmacroplay :0"
  alt + KP_Insert

#"/home/dave/bin/xmacro kr Alt_L br 1"
"echo ButtonRelease 1 | xmacroplay :0 ; echo KeyStrRelease Alt_L | xmacroplay :0"
  release + alt + KP_Insert

4) Start or reload xbindkeys:

% xbindkeys
# or if xbindkeys is running:
% killall -HUP xbindkeys

Although I will say that this has some trouble with launching compiz plugin hotkeys that I haven't figured out yet, running the lines outside xbindkeys works fine, but inside xbindkeys does not work. Haven't debugged that yet.

You must log in to answer this question.

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