# Momentary button on Dashboard

**URL:** https://discourse.nodered.org/t/momentary-button-on-dashboard/4906
**Category:** Dashboard
**Created:** [15 November 2018 17:02 UTC](https://discourse.nodered.org/t/momentary-button-on-dashboard/4906 "2018-11-15T17:02:59Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![hugobox](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hugobox/32/2948_2.png) [@hugobox](https://discourse.nodered.org/u/hugobox)
#### Post date: [29 November 2018 17:59 UTC](https://discourse.nodered.org/t/momentary-button-on-dashboard/4906/5 "2018-11-29T17:59:47Z")

</div>

Try the following, it should work for both mobile and desktop:

```auto
<div class="momentary">
   <md-button> Momentary Button</md-button>
</div>

<script>

(function($scope) {
    
$('.momentary').on('touchstart mousedown', function(e) {
    e.preventDefault(); //prevent default behavior
    $scope.send({"payload": true});
});

$('.momentary').on('touchend mouseup', function(e) {
    e.preventDefault(); //prevent default behavior
    $scope.send({"payload": false});
});
    
})(scope);
</script>
```

---

_[View the full topic](https://discourse.nodered.org/t/momentary-button-on-dashboard/4906)._
