Holding the TAB key down does not trigger right away

1 favourites
  • 11 posts
From the Asset Store
Game Triggers
$44.50 USD
50% off
Game Triggers is as versatile as a Swiss army knife, and will be a great resource for any type of game you're creating.
  • I'm not sure what is happening, but I want to fix it.

    When you hold or press the TAB key the VERY first time it does not immediately trigger. If you continue to hold it, it triggers after about 1 second.

    However, every time after that first tab, it then always triggers immediately as expected.

    is this a bug or is Construct doing with an invisible address bar or something? I would expect either to not work at all or always work.

    see example here. You have to run it FULLSCREEN or it freaks out on the address bar.

    dropbox.com/s/783newtnjvhxiqj/TABdelayTest.c3p

  • Run this script on start of the game/layout:

    // disable default Tab and Enter key behavior
    window.addEventListener('keydown', ev => {
     if (ev.keyCode===9 | ev.keyCode===13) {
     ev.preventDefault();
     }
    });
    
  • dop2000 that script worked for that little test, but it does not work in my game. any ideas of why it might not work? I'm using keycodes. although just tried it with TAB key directly and still doesn't work.

    I also have player controls in an #include but that shouldn't matter as long as that script gets run in OnStartOfLayout. Is that right?

  • I also realized that your script makes it so you can use the TAB without fullscreen. but in my game, that does NOT prevent that... its just like the script is not running. I tried adding it to all the startoflayouts...so I have no idea what is going on.

    my game project file is a few years old, is there some option I need to turn on in the editor maybe?

  • Figured it out. In my game I had Worker set to 'Yes' and in that test example project the worker was set to 'Auto'. That was the difference.

    I'm not sure what that means? Is worker not being used when I set it to Auto?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ashley I had Worker on 'Yes' but had a JS to prevent capturing tab key strokes and it wasn't working. When I set worker to 'Auto' the script worked. Does it mean worker is not running? And/or does worker prevent that kind of script?

  • When you enable worker mode your scripts run in a web worker, which don't have direct access to window and associated events. (Keyboard input can still be detected via runtime events, but you can't prevent default on them, because the event already finished on the main thread.) If you try to use window in a worker, it will throw errors which should appear in the browser console.

    Worker mode "auto" will default to using a worker, unless you add scripts to your project, in which case it turns off worker mode. This is because people tend to write scripts that access things like window and document, so the default is to allow that to work. This is noted in the manual here.

  • Ashley do you know if there is another non-scripting way to prevent that first delay in the TAB key? (see original post's dropbox link for example). Ideally I would like to use worker, although does any of this apply to NWjs?

    I'm using the tab key similar to other games where it pops up a map or weapon change options. And its just that initial press makes it feel slightly broken, but always and only the first time you do it during a play through, it doesn't happen again until you restart the application.

  • Have you tested if this delay actually happens in NWJS export? Maybe it's just the browser thing.

  • dop2000 I know there is a way to disable the F12 key for NWjs (Steam deafult key for screenshots) with args, so maybe I can do the same for the tab key without having to turn worker off.

  • yes this is a problem with NWjs. It pauses slightly only the first time you press and hold TAB. It's not good and it looks like I will be forced to remap the key.

    But I do have a control remap program I am including in the game so theoretically the player could reassign the TAB key, so maybe I have to force that not to work? PITA

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