Key remains pressed on alt key pressed

Hey, this is a generic issue which all should be facing in the third-player movement. If a player is moving and you press the alt key, the focus shifts to the window menu in the browser and when you unpress your movement keys, the player still keeps on moving as playcanvas never unregister that unpressed key. (More evident on firefox)

I wanted to know is there any workaround for this issue?

Steps to reproduce:

Side Note:
This issue is similar to the issue reported in github but it didn’t call onblur function and that’s why have to find another workaround for it.

The project cannot be opened by others apparently due to a inaccessible resource:

Its a playcanvas tutorial so it should open. You can try this https://playcanvas.com/editor/scene/961236

The project works now.

I was able to reproduce the same issue that you mentioned on Firefox.
The logic works as to be expected in MS Edge (Chromium) for me.

Pressing down the ALT key after pushing down the W, A, S, D keys seemed to initiate
the issue.

If I held down the ALT key before holding down either of the W, A, S, D keys’ the motion would cease as expected.

1 Like

You can probably listen to the window’s lose focus or blur or some other event so that the game pauses or it disables controls/etc when something like this happens.

You may also be able to override the modifier key in which case, I would check StackOverflow for a generic browser solution.

2 Likes