10

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...

3
  • I have exactly the same problem with my aspire p3, ubuntu 14.04, right click functions aren't working with touchscreen :(
    – user65390
    Apr 16, 2014 at 13:39
  • @user65390 have you tried freddi schiller's answer... Apr 20, 2014 at 21:58
  • 1
    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 Jan 28, 2016 at 12:54

6 Answers 6

12

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.

1
  • 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.
    – tanius
    May 5, 2019 at 20:01
6

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.

6
  • 1
    You should probably enable secondary click first, just by gsettings set org.gnome.desktop.a11y.mouse secondary-click-enabled "true" or via Dconf Editor. Sep 16, 2013 at 14:28
  • 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... Sep 16, 2013 at 14:49
  • 1
    @IsmailM Then, I think that you should speak about this with your seller/manufacturer... Sep 16, 2013 at 14:55
  • @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... Sep 17, 2013 at 15:55
  • @IsmailM Yes, you should. Sep 17, 2013 at 16:35
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 a command like this:

xsetwacom --set "your touchscreen product name" 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.

2

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.

1
  • 1
    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.
    – rakslice
    Sep 20, 2021 at 9:38
0

For those who have the Menu key on their keyboard, the note in the question about using that to create a right-click is actually a great idea. Since it is not obvious, here is how it works:

  1. Tap-and-hold the screen with one finger. Do not release the finger, as that would trigger a left-click, which might have undesirable effects in your application. Tap-and-hold however is like pressing and not releasing the left mouse button, and usually no action in an application results from that. But, the mouse pointer's position is already changed to where we want to right-click, which is why we do this step.

  2. Press and release the Menu key. Already on the key-press event, a right-click is triggered.

Obviously, this technique needs two hands, and is completely impossible on convertible notebooks in tablet mode. So it is of limited practical use.

0

You can use easystroke to create right-clicks with a modifier plus tap, such as Ctrl + Alt + tap. With additional configuration, this can be accessed single-handedly with just a touchscreen, see below.

This is quite nice, as "modifier plus tap" as a right-click cannot be configured with any of touchegg (does not recognize modifiers), mouseemu (does not recognize taps as they lack scancodes) or xsetwacom "…" set Button 1 … (does not recognize taps as finger input is not a button event in the driver).

1. Installation

easystroke program is only minimally maintained right now, but in the release notes they link to a recent Ubuntu package, built on Ubuntu 18.04. It worked well for me (Ubuntu 18.10 here). You can install it as follows:

wget http://openartisthq.org/easystroke/easystroke_0.6.0-0ubuntu8_amd64.deb
sudo apt install ./easystroke_0.6.0-0ubuntu8_amd64.deb

2. Configuration

  1. Start the program with easystroke.

  2. Under the second tab "Preferences", click "Gesture Button" and Ctrl + Alt + tap into the gray field. Ctrl + Alt seems to be the best choice of modifier, at least under LXQt, because:

    • Both Shift + click and Ctrl + click are used for multi-selection already and would become unavailable for that if assigned to easystroke.
    • Alt, Super and any combination involving Super will not be seen by easystroke. This is probably a LXQt or Openbox coniguration issue, but I could not resolve it so far.
  3. Under the first tab "Actions", click "Add Action".

  4. Configure your action with "Type: Command" and "Details: xdotool keyup ctrl alt; xdotool click 3". Adapt according to your chosen modifiers.

    Depending on the modifiers, clearing the modifiers first is important to prevent side effects. For example Shift + right-click in Chrome would lead to text selection. Also, clearing the modifiers explicitly is needed to prevent stuck modifiers when triggering these key presses with software (see section 3 below). Not clearing the modifiers on its own before executing the command could be considered a bug in easystroke.

  5. Click "Record Stroke" and record a single tap.

  6. You can disable the (here rather useless) popups under "Preferences → Appearance → Show Popups".

  7. You can limit this gesture recognition to only your touchscreen and perhaps pen input device under "Advanced → Devices".

Now, Ctrl + Alt + tap will create a right-click.

Note that easystroke has great gesture recognition for single-touch gestures ("drawing shapes on the screen") which you can use to automate many tasks while using the touchscreen. That's its main purpose, while right-click emulation is just a side effect.

3. Improvement: touch-only right-clicks

Now let's improve this configuration so that you can trigger right-clicks with just one hand and a touchscreen by (1) tapping on a special on-screen button that will mean "next tap is a right-click" and (2) then tapping on the screen just normally.

Here is a recipe for Lubuntu (LXQt) and using the Ctrl + Alt modifier chosen above, but the principle is the same in all desktop environments and with all modifiers: a custom quicklaunch entry in the panel.

  1. Create a custom icon for your quicklaunch entry and save it as ~/.icons/default/rightclick.png.

  2. Create a custom .desktop file and save it as .local/share/applications/rightclick.desktop, with the following content. Note that you have to supply username for the absolute path.

    [Desktop Entry]
    Name=Rightclick
    Comment=Next tap is a rightclick via Ctrl + Alt + easystroke gesture.
    Icon=/home/matthias/.icons/default/rightclick.png
    Exec=xdotool keydown ctrl alt
    Type=Application
    Categories=System;Utility;
    StartupWMClass=localdomain.rightclick
    
  3. Add another quicklaunch widget to your LXQt panel. While in principle you can also modify your existing one, I found that one placed in the bottom right corner of the screen is the most natural for right-handed operation and also accidental misclicks will only show the date (if that's what is next to the left, as in my case) instead of starting some large application.

  4. Open ~/.config/lxqt/panel.conf and adjust the new [quicklaunch2] section to refer to your custom .desktop file. Again, you have to supply username. Example how it may look:

    [quicklaunch2]
    alignment=Left
    apps\1\desktop=/home/username/.local/share/applications/rightclick.desktop
    apps\size=1
    type=quicklaunch
    
  5. Restart the LXQt panel to make the changes effective. For that:

    1. Go to "LXQt menu → Preferences → LXQt Settings → Session settings".
    2. Select "Basic Settings → LXQt Modules → Panel".
    3. Click "Stop".
    4. Click "Start".

     

    (You could also execute killall lxqt-panel && lxqt-panel in the Alt + F2 launch dialog, but that will interfere with the panel status recognized in the above mentioned dialog, and if you mix both techniques you'd have two panels running on top of each other, with one missing some panel icons. So better don't. This is still buggy.)

Also, if you have special hardware buttons at the side of the touchscreen, you could assign the xdotool keydown ctrl alt command to one of them instead.

4. Other improvements and troubleshooting

  • As a nice side effect, the above technique for touch-only right-clicks also enables single-handed access to all the other gestures you may have configured in easystroke. That's a pretty powerful feature for touchscreen usage automation.

  • When you configure other gestures in easystroke, be aware of the following bug: easystroke does not clear our chosen modifiers before doing the configured action. The action types "Key" and "Text" all result in key combinations together with Ctrl + Alt in the case above, which makes them unusable. As a workaround, choose action type "Command" instead and clear the modifiers yourself the same way as above. So to trigger Ctrl + V, the command would be:

    xdotool keyup ctrl alt; xdotool key "ctrl+v"
    

    (The xdotool option --clearmodifiers does not help here as it only disables the modifiers during the key combination to execute and re-applies them afterwards. Which in this case would make the next tap a right-click as per the technique above, but we would not want that in this case.)

  • If you ever have stuck modifiers during testing, pressing and releasing the modifier keys on the physical keyboard will fix the condition.

  • Sometimes during testing these things, my LXQt my keyboard and mouse events would become very messed up. In such a case, only logging out from the graphical environment and logging in again helped.

  • The cleanest way to implement single-handed touch-only operation in easystroke, including for the case of right-clicks as required here, would be that a tap on the easystroke panel icon brings it into the same internal state as our custom panel icon configured above, but without actually changing the keyboard modifier state because that can lead to stuck modifiers etc.. To show the easystroke window, one would then have to use the context menu of its panel icon. Obviously, that requires some changes in the easystroke code.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .