Control the mouse with the keyboard in Xorg

Are you also a tiling window manager lover like me? Have you taken the extra step of actually disconnecting your mouse peripheral? Well, to be honest I'm not that radical. Although I use a TWM exclusively for many years now, I keep my mouse connected for that odd app that I cannot really use otherwise.

However, recently the mouse I was using on my Raspberry Pi 3 coding station stopped working and I had to ditch it. For a few days I simply ignored the issue but at some point I realised that no matter how rarely, I did need to move the mouse pointer from time to time.

The mouse pointer has basically three different kinds of inputs, which usually are controlled by a mouse, but not necessarily:

Fortunately, as usual in the Unix world, there's often a workaround that suits your needs and in this case it's easy to set up. We can use the keyboard instead of the mouse to move around and click. More specifically the numeric keypad.

Configuration

In fact this used to be enabled by default, however most distros seem to have disabled it now. You need "XkbOptions" set to "keypad:pointerkeys" within an "InputClass" section in your Xorg configuration file like this:


Section "InputClass"
	Identifier "system-keyboard"
	MatchIsKeyboard "on"
	Option "XkbOptions" "keypad:pointerkeys"
EndSection

Alternatively you can also dynamically set this option while running Xorg with:


setxkbmap -option keypad:pointerkeys

Usage

Now that you have it configured, how do you use it?

Well, first you need to enable this feature by holding Shift and pressing Num Lock. If it doesn't work try holding Shift and Ctrl and pressing Num Lock. Then you can simply start using the numeric keypad to move around like depicted below:


    .    .    .
     .   .   .
      .  .  .
       7 8 9         <- up directions
 . . . 4 5 6 . . .   <- left/right
       1 2 3         <- down directions
      .  .  .
     .   .   .
    .    .    .

As for the mouse buttons: