# Detect long presses on mouse

**URL:** <https://phaser.discourse.group/t/detect-long-presses-on-mouse/537>\
**Category:** Phaser 3\
**Created:** [December 31, 2018, 4:01am UTC](https://phaser.discourse.group/t/detect-long-presses-on-mouse/537 "2018-12-31T04:01:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Legomite](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/legomite/32/92_2.png) [@Legomite](https://phaser.discourse.group/u/Legomite)\
**Post date:** [December 31, 2018, 4:01am UTC](https://phaser.discourse.group/t/detect-long-presses-on-mouse/537/1 "2018-12-31T04:01:53Z")

</div>

Is there a way to detect long presses in Phaser 3? I believe it was possible to count the duration of pointer down in Phaser 2, but I am having trouble finding an equivalent function in 3.

---

<div class="post-metadata">

**Author:** ![alb](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/alb/32/311_2.png) [@alb](https://phaser.discourse.group/u/alb)\
**Post date:** [December 31, 2018, 4:09am UTC](https://phaser.discourse.group/t/detect-long-presses-on-mouse/537/2 "2018-12-31T04:09:52Z")

</div>

Pointer has downTime and upTime properties that may be useful. According to the docs, they’re used for dragging but I imagine you can use them to test if the press was longer than a chosen threshold.

---

<div class="post-metadata">

**Author:** ![Legomite](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/legomite/32/92_2.png) [@Legomite](https://phaser.discourse.group/u/Legomite)\
**Post date:** [December 31, 2018, 6:22pm UTC](https://phaser.discourse.group/t/detect-long-presses-on-mouse/537/3 "2018-12-31T18:22:08Z")

</div>

I’m not quite sure how to use downTime and upTime effectively. The first downtime value appears to be set by the amount of time the game starts and when the pointerdown event is set. I thought this would be set by the length of the pointer down event

---

<div class="post-metadata">

**Author:** ![snowbillr](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/snowbillr/32/332_2.png) [@snowbillr](https://phaser.discourse.group/u/snowbillr)\
**Post date:** [December 31, 2018, 6:39pm UTC](https://phaser.discourse.group/t/detect-long-presses-on-mouse/537/4 "2018-12-31T18:39:58Z")

</div>

Yeah, `downTime` and `upTime` get set to the time at which the pointer was pressed down and released.

I think you could do something along the lines of checking the `pointer.downTime` in your `update` method and comparing it to the `time` parameter passed to the scene’s `update` method ([https://github.com/photonstorm/phaser/blob/v3.14.0/src/scene/Systems.js#L355](https://github.com/photonstorm/phaser/blob/v3.14.0/src/scene/Systems.js#L355)).

Keep in mind though that `downTime` doesn’t get reset when the pointer is released, so there may be better options out there.

---

<div class="post-metadata">

**Author:** ![jppresents](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/jppresents/32/1266_2.png) [@jppresents](https://phaser.discourse.group/u/jppresents)\
**Post date:** [April 28, 2019, 5:12pm UTC](https://phaser.discourse.group/t/detect-long-presses-on-mouse/537/6 "2019-04-28T17:12:53Z")

</div>

You can in addition to calculate the downtime by doing (currentTime- pointer.downTime) also check if pointer.upTime is lower than pointer.downTime - that would means it is still pressed.

(Because if the pointer has a down time more recent than the uptime, it is still beeing pressed down)
