Skip to main content

Raymii.org Raymii.org Logo

Quis custodiet ipsos custodes?
Home | About | All pages | Cluster Status | RSS Feed

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 seven 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.

Recently I removed all Google Ads from this site due to their invasive tracking, as well as Google Analytics. Please, if you found this content useful, consider a small donation using any of the options below:

I'm developing an open source monitoring app called Leaf Node Monitoring, 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 ~/.xbindkeysrc file:

# 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 Q and 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 use case.

Tags: accessibility , automation , blog , x , xbindkeys , xdotool , xorg