# How would I detect if a player is holding a button for too long

**URL:** <https://forum.makecode.com/t/how-would-i-detect-if-a-player-is-holding-a-button-for-too-long/7273>\
**Category:** Help\
**Created:** [April 9, 2021, 12:50am UTC](https://forum.makecode.com/t/how-would-i-detect-if-a-player-is-holding-a-button-for-too-long/7273 "2021-04-09T00:50:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![brandodon](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/brandodon/32/3625_2.png) [@brandodon](https://forum.makecode.com/u/brandodon)\
**Post date:** [April 9, 2021, 12:50am UTC](https://forum.makecode.com/t/how-would-i-detect-if-a-player-is-holding-a-button-for-too-long/7273/1 "2021-04-09T00:50:49Z")

</div>

I need to know this. I don’t see any blocks/commands that could help me out with this.

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [April 9, 2021, 1:49am UTC](https://forum.makecode.com/t/how-would-i-detect-if-a-player-is-holding-a-button-for-too-long/7273/2 "2021-04-09T01:49:32Z")

</div>

> **[Button Length detector](https://arcade.makecode.com/15340-22387-50832-41927)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

Maybe you could try something like this.

So what it does, is when the A button is pressed, then the current game time (in ms) is saved in a variable. In a forever loop, if checks if the A button is pressed and if it has been more than 2000ms since the button was first pressed.
