Is there a workaround to receive keyboard input events without having to click once to focus the window?

Here is a basic playground with an on keyboard observable https://playground.babylonjs.com/#458152

I’m using Chrome browser on a laptop computer. It seems like the keyboard observable doesn’t work unless I first click on the scene with my mouse. Camera controls don’t work either unless I click on the canvas at least once. This causes confusion when my players expect to be able to move the camera right away as soon as the scene loads.

Is there a work around for this?

PG - https://playground.babylonjs.com/full.html#458152#5

window.addEventListener("keydown",function (event) {
canvas.focus();
 })
1 Like

Thanks! This works.

1 Like