getTimer(id).stop() (since version 1.1)

Stops the timer early. Nothing happens if the timer has already elapsed.

When timers are stopped early, the script proceeds in the same way as if they had elapsed on their own: any callback command associated to the timer is executed and any wait command on the timer is resolved.

[js highlight=”8″ try=”true”]
newText(“instructions”, “Wait 3s or press Space”)
newTimer(“delay”, 3000)
newKey(“stop early”, ” “)
.settings.callback( getTimer(“delay”).stop() )

Will wait 3 seconds before proceeding, or will proceed if the space bar is pressed in the meantime.