Search

M y    b r a i n    h u r t s  !                                           w e                 r e a l l y                 t h i n k                   w h a t                y o u             k n o w

18 February 2009

Mouse emulation with keyboard

In many applications you can get around by pressing the Tab and arrow keys and then pressing Enter or Space when the widget you need is under focus. Remembering common shortcuts is always useful, but there are things which are impossible to do without a mouse, for example, clicking a button in a Flash applet.

As you probably know, you can emulate most mouse actions with the keyboard. To enable this feature in Kubuntu 8.10/9.04

  1. Open System Settings:
       systemsettings
    
    or click the Application Launcher > System > System Settings.
  2. Under the General tab select Keyboard & Mouse. To do it with the keyboard use Tab/Shift+Tab and the arrow keys. Window tabs (or pages) can be switched with Control+Tab or with Alt + underlined letter.
  3. Next, select Mouse on the left, and then Alt+N for Mouse Navigation.
  4. Select the option Move pointer with keyboard (using the num pad). (Alt+M)
  5. Click Apply (Alt+Y).

Note: If this looks complicated, there is actually a single shortcut for enabling mouse keys: Alt+Shift+NumLock.

Now you should be able to move the mouse pointer with number pad keys: 1, 2, 3, 4, 6, 7, 8, 9. If it does not work try pressing the NumLock key.

The table below shows the correspondence between mouse actions and keys on the number pad.

mouse action keyboard equivalent
Left-click 5
Left double-click '+'
Right click '-' on the numpad and then 5
Middle-click '*' on the numpad and then 5
Switch back to left click '/' on the numpad and then 5

The '-', '*', and '/' on the number pad select which 'mouse button' will be clicked when you press '5', therefore after you do a right-click with '-' and 5, you will have to switch back to left-clicking mode by pressing '/', otherwise you next click will still be on the 'right mouse button'.

Selecting text, dragging with keyboard

For some strange reason I did not find any official documentation on how to emulate mouse dragging with keyboard.

I have not checked other distros but on Kubuntu 8.10 you can do it by consecutively pressing the Del and '0' (Ins) on the number pad. This enables drag mode and you can now use 1-4/6-9 keys to drag whatever you clicked on. To finish dragging click 5.

I suppose that these features have to do with the xorg server, and are not [K]Ununtu-specific, so this probably should work with most distros.

Most of these keys also work on a MS Windows machine with one exception: drag-mode on Windows is enabled with the '0' key alone.