18

How can I emulate a mouse click on a keyboard on linux, e.g. by defining that my right CTRL-key should behave as if I clicked the right mouse button?

1

3 Answers 3

17

There is a "use numeric keypad as mouse" option for both kde and gnome. In kde 4.4 it's located under system settings -> Mouse -> Mouse navigation. I think that it's under accessability settings in gnome. The click actions appears on the keys around the numpad - the "+" key is right click and the "5" key is left click in kde.

If you don't run kde/gnome or want to use a more configurable solution, some sort of combination of these two programs should work:

http://www.semicomplete.com/blog/geekery/xdo.html

http://www.nongnu.org/xbindkeys/xbindkeys.html

Use xbindkeys to bind a keypress to

   echo "click 3" | xdo

in order to get a right click.

3
  • 2
    In KDE 4.7 this has been moved and renamed slightly: Hardware | Input Devices | Mouse | Mouse Navigation | Move pointer with keyboard. Thanks for the tip! Solved my problem perfectly (only have a stylus with no buttons...)
    – kwutchak
    Nov 28, 2012 at 5:54
  • 4
    xdo doesn't seem to do the trick for me, but xdotool click 3 does. Sep 14, 2017 at 16:28
  • 1
    In KDE plasma 5.27.4, the option to use the number pad for mouse navigation is under System Settings > Accessibility > Mouse Navigation May 21, 2023 at 15:10
11

You can create shortcuts in Keyboard > Custom Shortcuts and add the xdotool commands. For example:

Super + Z -> xdotool click 1 # left click
Super + X -> xdotool click 2 # middle click
Super + C -> xdotool click 3 # right click
2
  • 1
    Does this keep the mouse button in pressed state until the keyboard keys are released?
    – lucidbrot
    Apr 26, 2022 at 10:23
  • unfortunately not
    – J-Cake
    Sep 8, 2022 at 10:59
3

In CentOS 6.4 it's here:

System Menu --> Preferences --> Keyboard --> Mouse Clicks (tab) --> Enable the Keyboard to Emulate the Mouse (checkbox)

Now use the keypad '5' to left click (the other keypad numbers move the mouse).

Mouse Preferences (linuxtopia.org)

You must log in to answer this question.

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