onKeyUp not fired when Browser window lost focus

Hello,
I am having a problem with onKeyUp event.
This is scenario:
I implemented onKeyDown/onKeyUp to set/unsed a flag that let me know if the key is pressed.
The error happens when I hold the key and change to another window by clicking it. The onKeyUp is never fired and causes my flags remains in true as the key is still being pressed.

Is it a limitation? or Is there way to solve this?

Thank you in advance

Hi, Maximo

Yes, it’s a limitation of navigators, you may have to listen to the blur/focus event for your canvas and reset the key status

Huabin

Thank you, Huabin
I will try what you suggest.