Paul's Internet Landfill/ 2017/ Simulate Right Click Using the Keyboard

Simulate Right Click Using the Keyboard

The trackpad buttons on my netbook are failing. It takes a lot of time and pressure to press the mouse buttons.

I am using Debian with no desktop environment, so GNOME or KDE-specific fixes do not work for me.

I am able to deal with left clicks (and to some degree middle-clicks, although this does not work well) by enabling double-tap functionality for my trackpad. Here is the contents of /etc/X11/xorg.conf.d/50-synaptic-doubletap.conf :

Section "InputClass"
        Identifier "touchpad catchall"
        Driver "synaptics"
        MatchIsTouchpad "on"
    # Left click - 1 finger tap
    Option "TapButton1" "1"
    # Middle click - 2 finger tap
    Option "TapButton2" "2"
    # Highlight with double 1-finger tap
    Option "TapAndDragGesture" "1"

# This option is recommend on all Linux systems using evdev, but cannot be
# enabled by default. See the following link for details:
# http://who-t.blogspot.com/2010/11/how-to-ignore-configuration-errors.html
       MatchDevicePath "/dev/input/event*"
EndSection

Maybe I could have set up something similar for right-clicking, but I did not think of doing so at the time. Instead I tried changing Firefox to use "Caret Browsing" with F7. This puts a cursor on web pages that you can move to highlight text and selections. Then in principle you should be able to press the "Menu" button (the one that brings up context menus on the keyboard) and use that. This does not work well, especially when you are using the trackpad to scroll through web pages. The cursor does not follow the trackpad, so you move the arrow keys or press the menu button, and the page jumps back to the cursor location. Also you cannot use caret browsing in a tab's tab (so you can right-click and choose options like "Close Tabs to the Right").

To fix this I used the program keynav. I downloaded it using:

apt install keynav

Then I set up a ~/.keynavrc file. I modified the one from /usr/share/doc/keynav/keynavrc to keep the following key lines:

# Use 'clear' to blow away any previous keybindings
clear

# Use 'daemonize' to background ourselves.
daemonize

# Just simulate a right click.
ctrl+Menu start,click 3,end

The keynav program can do all kinds of neat things like selecting sections of the screen using only the keyboard. In those cases you want different keys to start and end the program. In my case I just wanted to simulate the one right-click, which I get by pressing ctrl+Menu . I know that the right thing to type in is Menu because that is the keysym of the keyboard key on my computer. (You could set it to a function key or something if that is more convenient.) You can find out what keysyms correspond to which keys using the xev program.

Once you have a .keynavrc file, you can then add the keynav call to your .xsession file. The daemonize option means you do not need to call keynav in the background.

This solution works well for me. It can be tricky to remember the precise key combination to bring up right clicks, but my muscle memory is learning.

Obviously this is best suited when you need right clicks to bring up context menus. For things like Inkscape I would use a mouse, but I do not want to be dependent on a mouse just so I can waste time on the Internet.