Growler Posted November 13, 2018 Share Posted November 13, 2018 I have a peculiar issue: if you accidentally hit tab in browser in game, it tabs to the URL bar as the next Browser element in line. What this means for MelonJS is if you were pressing a bound key, e.g., me.input.KEY.DOWN, at the time of tabbing, me.input.isKeyPressed('down') would remain true even if you're no longer pressing the key after focusing back on the game. 1) Why does this happen when you blur the game's focus? 2) How can I ensure isKeyPressed('down') is updated to current state onFocus into game? @obiot @Parasyte Quote Link to comment Share on other sites More sharing options...
obiot Posted November 14, 2018 Share Posted November 14, 2018 well that's an interesting one too, I was just looking at the code and indeed there is nothing to manage key status when the window/browser is losing status. So two solutions to that : you can disable the pauseOnBlur feature (true by default), which means the game won't pause when the window will loose focus, and that the keys will properly "behave" or (and this is what I would do in melonJS to fix this), is to register on the state pause or resume event (that are called when the window is losing/regaining focus) and simulate the required keydown or registered keys using `triggerKeyEvent(YOU_KEY, false) these are more workaround, but at least they won't conflict with a later fix in melonJS Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.