How To Quickly Toggle the Tap To Click Functionality of Your Trackpad [Mac]

Tap to Click Toggle.jpeg

When you type on a Mac laptop with a trackpad, do you inadvertently brush the trackpad with your palms or with the base of your thumbs? Doing so can cause your cursor to jump to unintended places on your screen, and really screw up whatever you’re working on. You can change your trackpad settings to disable Tap to Click to prevent this, but then you lose some convenience. What you really need is a quick way to toggle Tap to Click off and on. With a little AppleScript magic, you can do so.

Here is the script that you need:


-- want it on or off?
display dialog "Turn trackpad-clicking on or off?" buttons {"Cancel", "Turn Off", "Turn On"} default button 3 with icon note
if (button returned of result) is "Turn On" then
set theValue to 1
else
set theValue to 0
end if

 

 

 

 

-- open the preference pane
tell application "System Preferences"
activate
reveal (pane id "com.apple.preference.trackpad")
end tell

tell application "System Events"
tell process "System Preferences"
-- check the current value of the checkbox and change it if needed
tell checkbox "Tap to Click" of group 1 of window 1
repeat until exists (* wait until the object is accessible *)
delay 0.2
end repeat
if value is not theValue then click
end tell

-- leave the trackpad preference pane
click button "Show All" of group 1 of group 2 of tool bar 1 of window 1

 

 

 

 

-- hide system preferences
set visible to false
end tell
end tell

Copy and paste that into a new AppleScript window. Save it (File > Save) with whatever name you like, making sure to select “Application” in the “File Format” box. Also check the “Run Only” box before clicking the save button.

Now, when you navigate to the AppleScript application that you just saved and double click on it, a box will pop up, asking if you want to toggle Tap to Click on or off. After you make your selection, your Mac will automatically open and close windows, running through the steps that you’d normal need to go through manually in order to toggle Tap to Click.

To make this toggle option easily accessible, I’ve dragged it onto my dock, where I just need to click it. I also can access it with a couple of keystrokes, using Alfred.

Do you have any AppleScript tricks to share?

[Tip complied via two posts at the MacOSXHints Forums]

Front page trackpad image by D’Arcy Norman

Evan Kline

Hello, I'm Evan. I write about tech from my perspective – that of the average 40-something tech geek. You can also find me on Twitter and at my real-life job as a lawyer.    MORE ABOUT ME.

3 Comments:

  1. Thanks for that hint – it used to work very well with snow leopard and I loved it. But it seems to have ceased to work with lion. Is there a way to change the code in order to get the same toggle-tap-to-click-feature in lion?

    regards,
    Krid, Walldorf, Germany

Leave a Reply