Pressing key right before escape makes it "stuck" down

Description

I’m using code like this for player movement:

this.app.keyboard.isPressed(pc.KEY_A)

and I’m noticing that if:

1. I’m holding 2-3 keys down (for example: A, W, S)
2. Then I hit escape (to unlock my mouse)
3. Then I release the keys I was holding (A, W, S)
4. Sometimes PlayCanvas thinks some of those keys are still pressed. The code above, keyboard.isPressed(pc.KEY_A), will show true even though the key is not pressed.

  1. Press A (or any key)
  2. Press Escape within milliseconds of the key above.
  3. Release the A key.
  4. PlayCanvas still thinks the A key is pressed.

If I click on the experience to relock my mouse, that bug will cause the player to move by themself without any keys being pressed.

This can be undone by pressing the “stuck” key again.

Anyone delt with this issue before?

I’ve heard of a hardware limitation where some combination of motherboard or keyboard can not register more than a few keypresses at the same time. I feel like that was a bigger issue like 10-20 years ago, so may not be relevant at all.

The fact that it’s dependent on me pressing escape makes me think this is an engine/browser issue rather than a hardware/OS issue.

Specs

Browser: Chrome (135)
OS: Ubuntu 24.10
Rendering: WebGL 2, Wayland

I remember a similar issue with the mouse is still detecting a mouse press, but as far as I know this happens when the window is not focused anymore.

1 Like

Sounds similar.