# Trying to handle single press and press-and-hold on a button that only gives press and release

**URL:** <https://discourse.nodered.org/t/trying-to-handle-single-press-and-press-and-hold-on-a-button-that-only-gives-press-and-release/77879>\
**Category:** General\
**Created:** [24 April 2023 12:29 UTC](https://discourse.nodered.org/t/trying-to-handle-single-press-and-press-and-hold-on-a-button-that-only-gives-press-and-release/77879 "2023-04-24T12:29:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![fribse](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fribse/32/68270_2.png) [@fribse](https://discourse.nodered.org/u/fribse)\
**Post date:** [24 April 2023 12:29 UTC](https://discourse.nodered.org/t/trying-to-handle-single-press-and-press-and-hold-on-a-button-that-only-gives-press-and-release/77879/1 "2023-04-24T12:29:31Z")

</div>

I've made this flow to handle the single-press and press-and-hold for a button on my Home Assistant.  
The zigbee button only gives press and release.

 ![billede](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/3/23ca402c8960d8edc79978a7dc51e25ca61bba31.png)

I was wondering if there were a better way, than using a flow variable? It seems clumsy 🙂

> **[single-press and press-and-hold - Pastebin.com](https://pastebin.com/pRHhXkUm)**
>
> Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.

---

<div class="post-metadata">

**Author:** ![PdeJ](https://avatars.discourse-cdn.com/v4/letter/p/c89c15/32.png) [@PdeJ](https://discourse.nodered.org/u/PdeJ)\
**Post date:** [24 April 2023 17:27 UTC](https://discourse.nodered.org/t/trying-to-handle-single-press-and-press-and-hold-on-a-button-that-only-gives-press-and-release/77879/2 "2023-04-24T17:27:25Z")

</div>

Have a look [here](https://discourse.nodered.org/t/momentary-switch-or-button-normally-open/36768) which descibes how to make a momentary button, ie like your Press and Hold. It works both with mouse and touchscreens.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [24 April 2023 17:38 UTC](https://discourse.nodered.org/t/trying-to-handle-single-press-and-press-and-hold-on-a-button-that-only-gives-press-and-release/77879/3 "2023-04-24T17:38:13Z")

</div>

I might be wrong but that seems to be a dashboard button, whereas @fribse has a physical button and already gets a "button down" and a "button up" message.

I looked at this earlier but didn't reply because it's Home Assistant related, which might change things.

On the face of it though:  
Button down : start motor  
Button up: stop motor.

Can you explain why this is not enough?

---

<div class="post-metadata">

**Author:** ![PdeJ](https://avatars.discourse-cdn.com/v4/letter/p/c89c15/32.png) [@PdeJ](https://discourse.nodered.org/u/PdeJ)\
**Post date:** [24 April 2023 20:23 UTC](https://discourse.nodered.org/t/trying-to-handle-single-press-and-press-and-hold-on-a-button-that-only-gives-press-and-release/77879/4 "2023-04-24T20:23:14Z")

</div>

Agh quite so.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [23 June 2023 20:23 UTC](https://discourse.nodered.org/t/trying-to-handle-single-press-and-press-and-hold-on-a-button-that-only-gives-press-and-release/77879/5 "2023-06-23T20:23:21Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
