# Measure how long button (or clip!) is pressed for

**URL:** <https://forum.kirupa.com/t/measure-how-long-button-or-clip-is-pressed-for/38605>\
**Category:** Uncategorized\
**Created:** [December 26, 2003, 6:19pm UTC](https://forum.kirupa.com/t/measure-how-long-button-or-clip-is-pressed-for/38605 "2003-12-26T18:19:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![joecastro](https://avatars.discourse-cdn.com/v4/letter/j/df788c/32.png) [@joecastro](https://forum.kirupa.com/u/joecastro)\
**Post date:** [December 26, 2003, 6:19pm UTC](https://forum.kirupa.com/t/measure-how-long-button-or-clip-is-pressed-for/38605/1 "2003-12-26T18:19:35Z")

</div>

Does anybody know a simple way of measuring how long a button has been pressed for - had a look at gettimer but this seems to be an odd way of doing things - basically i want to say

onclick start timing -  
offclick end timing

var time = time button was pressed!

any ideas much appreciated… thanks - and if there is a simple solution (FOR ONCE!) that would be really cool!

measure how long button (or clip!) is pressed for

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 26, 2003, 7:21pm UTC](https://forum.kirupa.com/t/measure-how-long-button-or-clip-is-pressed-for/38605/2 "2003-12-26T19:21:19Z")

</div>

here’s one i made based on the FPS… check it out

[http://riddler05.home.comcast.net/timer.zip](http://riddler05.home.comcast.net/timer.zip)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 26, 2003, 7:25pm UTC](https://forum.kirupa.com/t/measure-how-long-button-or-clip-is-pressed-for/38605/3 "2003-12-26T19:25:25Z")

</div>

you could do a onclick get time on release get time sub one from the other

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 28, 2003, 12:20pm UTC](https://forum.kirupa.com/t/measure-how-long-button-or-clip-is-pressed-for/38605/4 "2003-12-28T12:20:39Z")

</div>

Yep, that’s the way

```auto
myButton.onPress = function () {
start_time = getTimer ();
}
myButton.onRelease = function () {
end_time = getTimer ();
trace ("The button was pressed for "+(end_time-start_time)+ " milliseconds.");
}

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 28, 2003, 3:29pm UTC](https://forum.kirupa.com/t/measure-how-long-button-or-clip-is-pressed-for/38605/5 "2003-12-28T15:29:29Z")

</div>

thanks everyone!
