Emulate mouse using keyboard
As I wrote in a previous post, I bought a wireless keyboard and mouse to use the computer from about 3 meters away. However, the mouse is not working.
While the combination of the window manager Awesome and the predominant use of command-line programs almost allow me to not need a cursor, some programs and web pages are not very friendly to someone without a mouse.
Until I buy another mouse, my temporary solution was to configure the numeric keypad to control the pointer movement, simulate the scroll wheel, and the buttons.
-
Download
xdotool
julio@julio-acer ~> sudo pacman -S xdotool
-
Add the following lines to
~/.xbindkeysrc
# Move to northwest (top-left) "xdotool mousemove_relative -- -10 -10" KP_Home # Move to north (up) "xdotool mousemove_relative 0 -10" KP_Up # Move to northeast (top-right) "xdotool mousemove_relative 10 -10" KP_Prior # Move to west (left) "xdotool mousemove_relative -- -10 0" KP_Left # Move to east (right) "xdotool mousemove_relative 10 0" KP_Right # Move to southwest (bottom-left) "xdotool mousemove_relative -- -10 10" KP_End # Move to south (down) "xdotool mousemove_relative 0 10" KP_Down # Move to southeast (bottom-right) "xdotool mousemove_relative 10 10" KP_Next # Left click "xdotool click 1" KP_Insert # Middle click "xdotool click 2" KP_Delete # Right click "xdotool click 3" KP_Enter # Scroll up "xdotool click 4" KP_Subtract # Scroll down "xdotool click 5" KP_Add
Modify the keys according to the output of xev
and you’re all set! I managed to simulate the basic
functions of the mouse using the keyboard.