Keyboard shortcut to toggle (enable/disable) laptop touchpad

I have a new dell laptop and I want to create a keyboard shortcut to disable and enable the touchpad. How do I do this?

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

Script to toggle Touchpad on/off with screen notification

Partial credit to this post (Enable/disable touchpad)

Create toggle-touchpad script

Create a new directory /home/USER/bin and then use gedit /home/USER/bin/toggle-touchpad. NOTE: Replace USER with your user ID. Copy and paste these lines into your editor:


# NAME: toggle-touchpad
# PATH: /home/$USER/bin
# DESC: Update pulseaudio output device when HDMI TV plugged / unplugged
# CALL: called from Keyboard Shortcut `Super`+`T`
# DATE: Created Dec 23, 2016.
# NOTE: Written for AU question:

# Use device number matching touchpad, in this case 14
if [[ $(xinput list 14 | grep -Ec "disabled") -eq 1 ]]; then
    xinput enable 14
    DISPLAY=:0 notify-send --urgency=critical --icon=/usr/share/icons/gnome/256x256/status/user-available.png "Touchpad enabled"
    xinput disable 14
    DISPLAY=:0 notify-send --urgency=critical --icon=/usr/share/icons/gnome/256x256/status/user-busy.png "Touchpad disabled"

exit 0

Mark toggle-touchpad script as executable

Save the file and exit the editor. Now flag the file as executable using chmod +x /home/USER/bin/toggle-touchpad

Assign toggle-touchpad script to keyboard shortcut

Open up System SettingsKeyboardShortcutsCustom Shortcuts+

This screen appears:

Keyboard shortcut to toggle (enable/disable) laptop touchpad

Fill in the Custom Shortcut fields like this:

  • Name = Toggle Touchpad
  • Command = /home/USER/bin/toggle-touchpad

Click Apply button to save.

The new entry appears with status Disabled. Right click on Disabled and use Super+Z (or any other unused shortcut combination). I wanted to use Super+T but that is already assigned to Nautilus Trashcan.

Modify toggle-touchpad script to different device number

The default device number is set at 14. To find out what your device number is use the following:

[email protected]:~/bin$ xinput
⎡ Virtual core pointer                      id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ Logitech Performance MX                   id=10   [slave  pointer  (2)]
⎜   ↳ Logitech K800                             id=11   [slave  pointer  (2)]
⎜   ↳ AlpsPS/2 ALPS GlidePoint                  id=14   [slave  pointer  (2)]
⎣ Virtual core keyboard                     id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
    ↳ Power Button                              id=6    [slave  keyboard (3)]
    ↳ Video Bus                                 id=7    [slave  keyboard (3)]
    ↳ Power Button                              id=8    [slave  keyboard (3)]
    ↳ Sleep Button                              id=9    [slave  keyboard (3)]
    ↳ Laptop_Integrated_Webcam_HD               id=12   [slave  keyboard (3)]
    ↳ Dell WMI hotkeys                          id=15   [slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard              id=13   [slave  keyboard (3)]
[email protected]:~/bin$ 

You can pick any device you like, ie Touchpad = 14, Webcam = 12, etc.

Which ever device number you use, simply open your /home/USER/bin/toggle-touchpad script and replace 14 with that device number.

Modify toggle-touchpad script to use different icons

When the "Touchpad enabled" / "Touchpad disabled" notification bubble is displayed, an icon is displayed left of the text. Stock icons are used from /usr/share/icons/gnome/256x256/status/ but you can change them.

For enabling touchpad this is displayed:

Keyboard shortcut to toggle (enable/disable) laptop touchpad

For disabling touchpad this is displayed:

Keyboard shortcut to toggle (enable/disable) laptop touchpad

Solution 2

Some computers have a function key for this purpose. For example, my Toshiba has FnF5.

You can do it rather easily via Settings — Mouse & touchpad in standard Ubuntu. (the icon with the cog wheel and wrench).

Otherwise you can do it with terminal commands in the lightweight Ubuntu flavours


synclient touchpadoff=1


synclient touchpadoff=0

And you can make aliases for these commands, or a ‘touchpad-toggle alias’.


man synaptics

for more details.

   Option "TouchpadOff" "integer"
          Switch off the touchpad.  Valid values are:

          0   Touchpad is enabled
          1   Touchpad is switched off (physical clicks still work)
          2   Only tapping and scrolling is switched off
          When  the  touchpad is switched off, button events caused by a
          physical button press are still interpreted. On a ClickPad,
          this includes software-emulated middle and right buttons as
          defined by the SoftButtonAreas setting.

Solution 3

Sources here, here, also here.

This script also shows a notification with icon, as well as message.

# This shell script is PUBLIC DOMAIN. You may do whatever you want with it.


if [ ! -e $TOGGLE ]; then
    touch $TOGGLE
    xinput disable 14
    notify-send -u low -i mouse --icon=/usr/share/icons/HighContrast/256x256/status/touchpad-disabled.png "Trackpad disabled"
    rm $TOGGLE
    xinput enable 14
    notify-send -u low -i mouse --icon=/usr/share/icons/HighContrast/256x256/devices/input-touchpad.png "Trackpad enabled"

(in the above commands 14 is a variable to be identified with xinput list)

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply