How to emulate a right mouse button click on touchscreen?

30,801

Solution 1

You need to enable the secondary click (as AliNa commented) with gsettings set org.gnome.desktop.a11y.mouse secondary-click-enabled "true" or with dconf editor.

Then it is possible that Ubuntu handles the touchscreen partially like a touchpad, where a touch does not trigger mouse-press. Instead you need to short-tap + touch-and-hold.

Solution 2

Just keep touching the screen for 2 or 3 seconds and what is called "right menu" should appear. This is the normal way to emulate a right click on any touchscreen.

Solution 3

If you have a Wacom touchscreen (using driver xf86-input-wacom) and it is capable of at least two-finger multi-touch, then the following will produce a right-click:

  1. Tap-and-hold with the first finger.
  2. Now tap with the second finger.

If it does not work yet, find out the product name of your touchscreen from xinput --list and then enable this feature with:

xsetwacom --set "[your touchscreen product id]" Gesture on

To make this change permanent, see my other answer for the technique.

Unlike the long-press right-clicks under Gnome / Ubuntu Shell, this works in all desktop environments because it is a (legacy) driver-level feature. Just be aware that it may cause issues with left-clicking by touchscreen in some programs, which is why I had to disable it on my system.

Solution 4

Out of my answers to this question, this is my personal favourite.

If you have a touchscreen that supports at least two-finger multi-touch input, you can install touchegg and configure it to interpret (for example) a two-finger tap as a right-click. I tried this under Lubuntu 18.10 and it works.

1. Installation

touchegg is available in the Ubuntu 18.10 repositories, so you can install it simply like this:

sudo apt install touchegg

To start it, execute touchegg. When executing it in a terminal you can check from its output if it detects your multitouch gestures correctly.

To make touchegg start automatically for each LXQt session, simply add it to Autostart (LXQt menu → Preferences → LXQt Settings → Session settings → Autostart).

2. Ways to configure touchegg

You can configure touchegg in two alternative ways:

  • Configuration with a config file. Edit the file ~/.config/touchegg/touchegg.conf. To make the changes effective, execute the following in a terminal or via the Alt + F2 run dialog:

    killall touchegg; touchegg
    
  • Configuration with a GUI. touchegg has a nice configuration GUI called touchegg-gui, which is seen here. However, it is not part of the touchegg Ubuntu package. Alternatively, you can install the GUI touchegg-gce as described here. touchegg-gce works, but you have to manually restart touchegg after saving changes to its configuration file, again by executing:

    killall touchegg; touchegg
    

3. Configuration for emulating a right-click

To configure a two-finger-tap right-click, you can use this config file for ~/.config/touchegg/touchegg.conf:

<touchégg>
        <settings>
                <property name="composed_gestures_time">0</property>
        </settings>

        <application name="All">
                <gesture type="TAP" fingers="2" direction="">
                        <action type="MOUSE_CLICK">BUTTON=3</action>
                </gesture>
        </application>
</touchégg>

Comments on the touchegg configuration:

  • Two-finger-tap right-clicking as shown above is currently already contained in the default configuration file that comes with touchegg. (Ubuntu 18.10 here.)

  • The program will wait composed_gestures_time (given in milliseconds) for you to complete your actions for gestures that consist of multiple parts (like touble taps), and only then interpret them. So when using touchegg only for single-part gestures such as two-finger-tap right-clicking, we can set this to 0 to prevent any noticeable delay in the actions. This is also the default in the config file created by touchegg.

  • At least with my touchscreen, two-finger-tapping is not recognized when touching the screen with both fingers at exactly the same time. But when there is even a very small time gap (so that two taps can be heard, probably ≥10 ms), it works reliably. So I just move my index finger and middle finger with a small vertical gap towards the screen, and it works reliably.

  • The right-click will be triggered at the location of that finger (out of the two in this gesture) that touches the screen first.

  • touchegg lets all events that it was not configured for bubble up to the appication under the cursor to be interpreted there. This is good because the native pinch-zoom etc. implemented in Chromium, Chrome, Evince for example works way more smooth than via touchegg.

  • touchegg can be used alongside the (highly recommendable!) single-touch gesture recognition software easystroke without interference. Of course, they should not be configured to be triggered by the same events.

4. Troubleshooting

  • touchegg may stop to work after a suspend-and-resume cycle. I still have to find a way so that it restarts automatically.

  • At least for me and others, touchegg will only interpret touch events on the touchscreen, not on the touchpad. In this case this is desired. It may be because my touchpad uses a driver that does not expose multi-touch events to the X server (synaptics rather than libinput). You can check which devices touchegg binds to by starting it with GEIS_DEBUG=3 touchegg.

  • If touchegg causes a kind of "stuck half click" for all programs, where taps will move the mouse pointer but no longer trigger left-clicks: this is not its normal behavior. Under Ubuntu 18.10 with LXQt, I did not have this at first, but then had it across several re-starts of touchegg and even restarts of the whole computer. It disappeared after starting the default Ubuntu desktop and then returning to LXQt.

    A fix in the touchegg configuration file by setting up an additional gesture for one-finger tapping will fix the "stuck half click", but other misbehavior of touchegg that comes with this bug remains, so it is not a real fix. That misbehavior includes that (1) touchegg will now also consume all events that it is not configured for, at least those for one finger, and (2) some Java based programs (freemind for example) will now suffer from a reverse issue with "stuck half clicks", where the cursor position will be stuck but left mouse button clicks will register. This is temporarily fixed by doing a two-finger action in the Java-based program, for touchegg to recognize.

Share:
30,801

Related videos on Youtube

Ismail Moghul
Author by

Ismail Moghul

Updated on September 18, 2022

Comments

  • Ismail Moghul
    Ismail Moghul over 1 year

    My new touchscreen laptop does not have the menu button (i.e. the one behaves like a right mouse click) - the one usually next to the right ctrl.

    since you cannot left click by touch, I am trying to create a custom keyboard Shortcut for Alt GR for this function (under System > Keyboard > Shortcuts > Custom Shortcuts)

    When using the xev command with an onboard keyboard (that has the menu button), I have found out that the button info is:

    KeyRelease event, serial 42, synthetic NO, window 0x4800001,
        root 0xab, subw 0x0, time 2544690, (1236,607), root:(1302,1050),
        state 0x0, keycode 135 (keysym 0xff67, Menu), same_screen YES,
        XLookupString gives 0 bytes: 
        XFilterEvent returns: False
    

    However, I have no idea what to do with this info...

    btw I am using a Ubuntu 13.04.

    Any help would be most appreciated...

    • user65390
      user65390 about 10 years
      I have exactly the same problem with my aspire p3, ubuntu 14.04, right click functions aren't working with touchscreen :(
    • Ismail Moghul
      Ismail Moghul about 10 years
      @user65390 have you tried freddi schiller's answer...
    • Bhikkhu Subhuti
      Bhikkhu Subhuti over 8 years
      you should edit this question to remove the geekyness. Simply say, how to right click on touchscreens? The question, now answered seems too technical to actually match the answers
  • AliN
    AliN over 10 years
    You should probably enable secondary click first, just by gsettings set org.gnome.desktop.a11y.mouse secondary-click-enabled "true" or via Dconf Editor.
  • Ismail Moghul
    Ismail Moghul over 10 years
    I entered the above command into the terminal and then even went to universal settings and reduced the acceptance delay to the min. however this still does not solve the problem - when I use a mouse, the menu does appear but when using the touchscreen it doesn't work...
  • Ismail Moghul
    Ismail Moghul over 10 years
    @RaduRădeanu I brought this laptop from john lewis with Windows 8 on it (and the touchscreen function is working properly on windows 8). Do you still think I should chat to them because I installed ubuntu myself...
  • Radu Rădeanu
    Radu Rădeanu over 10 years
    @IsmailM Yes, you should.
  • tanius
    tanius about 5 years
    Sadly, this technique is limited to Gnome3 based desktop environments, such as stock Ubuntu. Long-press for right-click also works in Chrome / Chromium out of the box, but only because it does its own handling of touch events.
  • rakslice
    rakslice over 2 years
    To belabour the point in the third bullet point of section 4, if you actually do a right click gesture with touchegg in a window it breaks left clicks for that window after that. And in the current version (2.0.11), configuring a 1-touch rule for left click has no effect, so doesn't work as a workaround.