HOWTO use the numeric keyboard keys as mouse in XOrg

From LinuxReviews
Jump to navigationJump to search

XOrg comes with built-in mouse emulation using the keyboards numeric keypad. The trick is to use Shift+NumLock to toggle the use of the numeric pad as a keyboard mouse on and off after enabling this feature in your X configuration.

HOWTO enable keyboard mouse keys

Mouse emulation with the number pad keys used to be a default standard feature of Xorg/X11. Most of the modern GNU/Linux distributions have disabled this still built-in feature. You can and should enable it manually either by creating or editing a configuration file in the folder /etc/X11/xorg.conf.d (just create it if you're on a distribution like Ubuntu where it doesn't exist in the default installation).

What you need is XkbOptions with the value keypad:pointerkeys. Just add this line to /etc/X11/xorg.conf.d/00-keyboard.conf if you have it:

Option "XkbOptions" "keypad:pointerkeys"

or create a new file looking like this if you don't:

File: /etc/X11/xorg.conf.d/00-keyboard.conf
Section "InputClass"
        Identifier "system-keyboard"
        MatchIsKeyboard "on"
        Option "XkbOptions" "keypad:pointerkeys"

This feature can also be activated while running X by running this command in a terminal:

setxkbmap -option keypad:pointerkeys

Controlling your keyboard "mouse"

Hold Shift and press Num-Lock to enable keyboard mouse emulation. You may hear a short beep depending on computer and GNU/Linux flavor. You may actually have to hold Shift and Ctrl and press Num-Lock on some systems.

Laptops without a real number pad will require you to hold the FN key to use the "numeric pad", which makes this tricky.

To move the mouse pointer:

  • 7, 8 ,9 are the up directions
  • 4, 6 are left and right
  • 1, 2, 3 are the down directions

Clicking using the emulated mouse buttons is slightly tricky and you have to learn the trick:

  • / selects the left mouse key (press it twice for a doubleclick; and thrice for a tripleclick)
  • * selects the middle mouse key
  • - selects the right mouse key

Do note that / and * and - will only select and make a mouse button active. To actually use the active mouse button you need to press:

  • Press 5 or + do to the actual mouse-click
  • Press 0 / Ins to press and hold the selected mouse key (e.g. for dragging something)
  • Press . / Del to release the currently selected mouse key.

The numpad emulated mouse is easy to use if you get used to first selecting the mouse key you want to (ab)use by pressing / for left mouse key, - for the right botton or * for the middle and then pressing 5 to do the actual click (or Ins/Del for drag-and-drop).

Example: To do a mouse-click with the middle button you first press the * key and then 5 to click.

Without the mouse in browsers, etc

It is easy to navigate browsers without mouse or any sort. Just use the arrow keys, enter does what leftclick does, the menu key does what the right click does and ctrl+enter acts like the middle click.