# How could I send a programmatic button click to a scene?

**URL:** <https://forum.babylonjs.com/t/how-could-i-send-a-programmatic-button-click-to-a-scene/12818>\
**Category:** Questions\
**Created:** [July 24, 2020, 2:59pm UTC](https://forum.babylonjs.com/t/how-could-i-send-a-programmatic-button-click-to-a-scene/12818 "2020-07-24T14:59:32Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![kmitov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/kmitov/32/4969_2.png) [@kmitov](https://forum.babylonjs.com/u/kmitov)\
**Post date:** [July 25, 2020, 5:41am UTC](https://forum.babylonjs.com/t/how-could-i-send-a-programmatic-button-click-to-a-scene/12818/9 "2020-07-25T05:41:00Z")

</div>

Ahh, the internet, we build, we love it and we pretty much hate it.

Turns out that you can not call canvas.focus(). You need to have element.tabIndex set to like element.tabIndex="-1" and only then you can set the focus. And I think I don’t need the timeout for the tick

```auto
      canvas.tabIndex = -1;
      canvas.focus();
      canvas.dispatchEvent(new KeyboardEvent('keydown',{'key':'Delete'}))

```

---

_[View the full topic](https://forum.babylonjs.com/t/how-could-i-send-a-programmatic-button-click-to-a-scene/12818)._
