The focus() call is not in effect yet when the event is sent when doing in sequence: it seems you need to wait for a javascript tick between setting the focus and sending the event:
Too soon. Too soon. I still can’t get it working in a test and cant reproduce it in the playground. Worst possible situation. Looking at it. I can see it is a problem with the focus because when setting the focus by hand (clicking the canvas) it works. But setting the focus in the code does not set the focus.
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