Skip to content

Unable to get camera movement from a button child of the canvas element #1

Description

@frastlin

Hello,
I am trying to get Babylon working using this template, but for some reason, I am unable to move the camera with the arrow keys.
I am unable to access any keyboard input without the following code:

src/BabylonScene/index.js line 86:

	<canvas
		{...opts}
		ref={this.onCanvasLoaded}
		role="image"
	>
		<button>Focus button</button>
	</canvas>

src/Viewer/index.js, line 26:

canvas.addEventListener("keydown", e=>{
	if(e.key === "f") console.log(camera.position)
})

With the above code I can get "f" to work and log the camera.position, but none of the arrow keys work.
Are you able to reproduce this?
I opened an issue on the forums, but there has been no solution yet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions