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: FalseHowever, I have no idea what to do with this info...
btw I am using a Ubuntu 13.04.
Any help would be most appreciated...
36 Answers
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.
1Just 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.
6If 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:
- Tap-and-hold with the first finger.
- 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 onTo 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.
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 toucheggTo 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; toucheggConfiguration with a GUI.
touchegghas a nice configuration GUI calledtouchegg-gui, which is seen here. However, it is not part of thetoucheggUbuntu package. Alternatively, you can install the GUItouchegg-gceas described here.touchegg-gceworks, but you have to manually restarttoucheggafter 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 usingtoucheggonly for single-part gestures such as two-finger-tap right-clicking, we can set this to0to prevent any noticeable delay in the actions. This is also the default in the config file created bytouchegg.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.
touchegglets 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 viatouchegg.toucheggcan be used alongside the (highly recommendable!) single-touch gesture recognition softwareeasystrokewithout interference. Of course, they should not be configured to be triggered by the same events.
4. Troubleshooting
toucheggmay 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,
toucheggwill 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 (synapticsrather thanlibinput). You can check which devicestoucheggbinds to by starting it withGEIS_DEBUG=3 touchegg.If
toucheggcauses 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 oftoucheggand even restarts of the whole computer. It disappeared after starting the default Ubuntu desktop and then returning to LXQt.A fix in the
toucheggconfiguration file by setting up an additional gesture for one-finger tapping will fix the "stuck half click", but other misbehavior oftoucheggthat comes with this bug remains, so it is not a real fix. That misbehavior includes that (1)toucheggwill now also consume all events that it is not configured for, at least those for one finger, and (2) some Java based programs (freemindfor 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, fortoucheggto recognize.
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:
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.
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.
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
sudo apt install ./easystroke_0.6.0-0ubuntu8_amd64.deb2. Configuration
Start the program with
easystroke.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.
- Both Shift + click and Ctrl + click are used for multi-selection already and would become unavailable for that if assigned to
Under the first tab "Actions", click "Add Action".
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.Click "Record Stroke" and record a single tap.
You can disable the (here rather useless) popups under "Preferences → Appearance → Show Popups".
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.
Create a custom icon for your quicklaunch entry and save it as
~/.icons/default/rightclick.png.Create a custom
.desktopfile and save it as.local/share/applications/rightclick.desktop, with the following content. Note that you have to supplyusernamefor 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.rightclickAdd 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.
Open
~/.config/lxqt/panel.confand adjust the new[quicklaunch2]section to refer to your custom.desktopfile. Again, you have to supplyusername. Example how it may look:[quicklaunch2] alignment=Left apps\1\desktop=/home/username/.local/share/applications/rightclick.desktop apps\size=1 type=quicklaunchRestart the LXQt panel to make the changes effective. For that:
- Go to "LXQt menu → Preferences → LXQt Settings → Session settings".
- Select "Basic Settings → LXQt Modules → Panel".
- Click "Stop".
- Click "Start".
(You could also execute
killall lxqt-panel && lxqt-panelin 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:easystrokedoes 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
xdotooloption--clearmodifiersdoes 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 theeasystrokepanel 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 theeasystrokewindow, one would then have to use the context menu of its panel icon. Obviously, that requires some changes in theeasystrokecode.