Skip to content

My game starts on click but I can't control the player with the keyboard

After I click to start, the keyboard does nothing and I can't move. Is it a focus problem?

Category: Controls & physics

Answer from Cinevva Team ✓ Accepted

Yes, this is usually a focus issue. The game canvas needs keyboard focus before it receives key events. Ask the assistant to give the canvas focus on start and to capture key events on the window, something like "focus the game canvas when the game starts and listen for keydown on the window." If you embed the game in a frame, the frame also needs focus, so a click-to-start overlay that focuses the canvas is the reliable fix.


Join the live discussion or ask your own question →