I'd like to be able to send middle mouse clicks from a keyboard key, for example, the right control key (keycode 105 on my keyboard).

I can remap it using xmodmap like so:

xmodmap -e "keycode 105 = Pointer_Button2"

But it only seems to work if I have mousekeys enabled, by running one of the following:

  • Shift-Numlock
  • dconf write /org/gnome/desktop/a11y/keyboard/mousekeys-enable true
  • xkbset m && xkbset exp =m

This remaps the numeric keypad to control the cursor.

Is there some way I can get X to accept mouse events from keyboard keys without converting the numpad to a cursor control?


Yes it can :) You have two choise. A smart but dirty way is to use xmodmap -e to remap all keypad to corrensponding value on keyboard. Like KP9 to 9 (the proccess is the same as you do for mouse button)

The second way is to go /usr/share/X11/xkb/compat/mousekeys, read the file carefully and remove or comment those who are in relation with keypad. (you can comment is c++ way using //)

After edit, reboot the X or your computer and enabling xkb mouse controlbit by xkbset m won't affect keypad anymore.

PS: by the way I want to remap a key to mouse button 9 but Pointer_Button9 is not defined :( any comment?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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