Mouse movement via the keyboard with xdotool and xbindkeys
Published: 13-09-2016 | Author: Remy van Elst | Text only version of this article
Table of Contents
I had a request from a friend to figure out how she could use her mouse via thekeyboard. Normally you would use Mouse Keys, but she uses a kinesisfreestyle2 which has no numpad. By using xbindkeys together withxdotool we can use our own key combination to move the mouse keys.
Make sure the packages are installed:
apt-get install xdotool xbindkeys
Use your window manager to let
xbindkeys start at startup.
Append the following to your
# ALT SHIFT # 10 up"xdotool mousemove_relative --sync -- 0 -10"Mod1+Shift+w# ALT SHIFT S# 10 down"xdotool mousemove_relative --sync -- 0 10"Mod1+Shift+s# ALT SHIFT A# 10 left"xdotool mousemove_relative --sync -- -10 0"Mod1+Shift+a# ALT SHIFT D# 10 right"xdotool mousemove_relative --sync -- 10 0"Mod1+Shift+d# ALT SHIFT Q# left click"sleep 1 && xdotool click 1"Mod1+Shift+q# ALT SHIFT E# right click"sleep 1 && xdotool click 3"Mod1+Shift+e
This will let you use the
WASD combined with ALT and SHIFT to move the mouse.The
E keys can be used to left and right click, but that is with adelay of one second. Otherwise some applications like firefox interpret theSHIFT as an instruction to open a new window which is not what we want in thisuse case.