Browser Focus / KeyDown Problem - is there a solution?

Get help using Construct 2

Post » Thu Jun 18, 2015 6:28 pm

Hi, I submitted this as a bug report but the issue is caused by the browser having no access to key down and key up triggers when it is not in focus.

Have a look at this simple example and you'll see that, if a key is down when the browser becomes out of focus, the c2 engine never receives a key up trigger - so when you return to the game it continues as if the key is still being continually pressed, even though it is not!

When running in a browser tab this can be detected by the Page is Visible Browser condition, but if you run a game in a stand-alone browser- or NW window - then nothing gets triggerd that can be detected by c2. This is a real problem when running a game in NW... and I can't think of a robust work-around to detect when something else on the desktop has been put into focus.

I have tried using the Browser: On Suspended / On Resumed / Page is Visible conditions. However, none of these work when the browser/NW window is stand-alone, they only register when if page/tab/window is minimized...

Is this a limitation of javascript - that there is never going to be a way to detect a key-up condition if that change happened when the window was out of focus, or is this a bug in the Browser object, because the Page is Visible is not detecting all out of focus conditions?

Thanks.
Learning other engines, but C2 still rocks. Image Image Image Image
B
80
S
22
G
95
Posts: 2,417
Reputation: 57,671

Post » Sat Jun 20, 2015 1:24 am

A small Friday night bump back to the top.

The more I think about this, the more of a potential problem this could be for non-browser (NW) based games if they are not always played in full screen. Anyone for trying to sell a game with apparently run-away controls? No, me neither... :/

@spongehammer - I tag you here because it appears that my earlier advice about your game in immediate full screen might not have been the best advice after all.... Sorry!
Learning other engines, but C2 still rocks. Image Image Image Image
B
80
S
22
G
95
Posts: 2,417
Reputation: 57,671


Return to How do I....?

Who is online

Users browsing this forum: BadMario, Elliott and 7 guests