Lost Focus Causes Keyboard Persistence...

0 favourites
  • 8 posts
From the Asset Store
Total customisation of the input! You can combine inputs from all peripherals. Make your game accessible for everyone!
  • Problem Description

    When player is holding down a key on the keyboard and something takes the focus away from the game. Either an errant click outside of the game window, a right click outside of the game window, a steam alert popping up over the game, etc the game 'remembers' the key that was down and persists with pushing it even though window is not in focus. when returning to the game window, the key will continue to be pushed, even if it's not actually being pushed... the only way to 'fix' the issue is to hit that key again, causing it's state to reset.

    Attach a Capx


    Description of Capx

    Simple 8 direction movement via arrow keys...

    Steps to Reproduce Bug

    • Preview CAPX
    • Use arrow keys to control player.
    • While holding a direction, right click a 'non-game' area... click the 'search' bar of the browser window, alt-tab away from the game, etc.
    • While focus is lost, release the arrow key you were holding.
    • Upon returning to the game, notice the direction key is still 'held' indefinitely.
    • "Fix" the issue by re-touching the arrow key that the game 'thinks' is down. This will reset the state.

    Observed Result


    Expected Result

    Lose focus to game = key pressed / touch states are forced to 'let go'.

    Affected Browsers

    • Chrome: (YES)
    • FireFox: (YES)
    • Internet Explorer: (YES)

    Operating System and Service Pack

    Windows 7

    Construct 2 Version ID

    Construct 178

  • i thought perhaps if there was even a 'release all keys' option in the keyboard object i could simply do it via an action like "On Suspend: Release Keys" or something but "On Suspend" doesnt seem to apply to something like a 'right click', so I dont know if this is fixable...

  • I believe this happens to all keyboard input when it comes to loosing focus. In my case, any event that uses [When Key is down] will cause the key to constantly hold when looses focus even when the key isn't physically held down any more.

    EDIT* It may happen to consoles too

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Is there some workaround for this, you think? other than checking every tick for all keys and releasing if theyre not actually down?! (Isnt it already doing that?)

  • I don't think this is a C2 issue.

  • Well I appreciate that, and Im certainly not trying to argue or be offensive, but it's an issue in that games created with C2 have this problem, even when built as standalone executables. Other commercial games and applications do not have this issue.

    If i had the capabilities to code my game from scratch, this is something I would try to resolve. Because I'm relying on C2 and have no way to resolve (to my knowledge) using the tools within C2, i'm reporting it as a bug.

  • Sorry, I don't think there is anything we can do about this. If the browser loses focus then the browser does not fire the key up event. I think some native apps are affected by this too, as well as any other engine/framework running in a browser. It's more to do with how the OS deals out events to different apps.

  • dang, thats a bummer.. A couple testers have said it can be annoying and i haven't even done the full release / passed keys to all kickstarter backers yet. (small sample size)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)