Mouse movement via the keyboard with xdotool and xbindkeys
Published: 13-09-2016 | Author: Remy van Elst | Text only version of this article
❗ This post is over five years old. It may no longer be up to date. Opinions may have changed.
I had a request from a friend to figure out how she could use her mouse via the keyboard. Normally you would use Mouse Keys, but she uses a kinesis freestyle2 which has no numpad. By using xbindkeys together with xdotool we can use our own key combination to move the mouse keys.
I'm developing a desktop monitoring app, Leaf Node Monitoring, open source, but paid. For Windows, Linux & Android, go check it out.
Consider sponsoring me on Github. It means the world to me if you show your appreciation and you'll help pay the server costs.
You can also sponsor me by getting a Digital Ocean VPS. With this referral link you'll get $100 credit for 60 days.
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.
E keys can be used to left and right click, but that is with a
delay of one second. Otherwise some applications like firefox interpret the
SHIFT as an instruction to open a new window which is not what we want in this