I have a perennial problem with accidentally brushing touchbar icons. I hit the escape key all the time! One of the reasons I got BTT was so that I could add a long-press delay to the 'esc' button....but the built-in long press is long! A more convenient solution for me is to have a double-tap function. I figured out a straightforward way to do it. In this case, 'esc' (or any button for that matter) will do nothing unless it is tapped twice, quickly.
Step 1 - Create a touchbar button, and set it to trigger an asynchronous applescript. The async is important if you want the wait for a second tap to timeout and reset after a while. Leave the applescript blank for now.
Step 2 - Before adding the actual applescript, create a named trigger under "other triggers" that performs the function you want. In my case, it simply executes the 'esc' key.
Step 3 - Use the following applescript as the action in your touchbar button created in step 1, but change the trigger_named to the name of the named trigger you created in step 2. You may also change the delay to any number of seconds you like - this is the second-tap-reset timeout.
tell application "BetterTouchTool 2" set is_second_click to get_string_variable "sec_click_e" end tell if is_second_click = "yes" then tell application "BetterTouchTool" set_persistent_string_variable "sec_click_e" to "no" trigger_named "esc" end tell else tell application "BetterTouchTool" set_persistent_string_variable "sec_click_e" to "yes" end tell delay 2 tell application "BetterTouchTool" set_persistent_string_variable "sec_click_e" to "no" end tell end if
Last - you can use this method for any number of double-tap buttons. Just repeat the above steps...BUT, make sure you change the name of the persistent string variable for each one so that they don't interfere with one-another.