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

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

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