Browser moving when pressing keys

0 favourites
  • 6 posts
  • Hi Constructors League!!

    I have a little problem that I do not know how to fix!

    We are almost ready to put our game on line (BETA) and I am customizing the index page of the construct exported game(index.html).

    Te question is : How can I block the browser to move when pressing the arrow keys (Up and Down). My game needs those keys to move the main character but when doing that, the entire page moves with it.

    I know this is not a direct Construct issue but if some one can give me a hand I will be eternally grateful.

    Thank you for reading!!

  • To maintain the browser usability when viewing C2 games, C2 only blocks keys which are used. Behaviors with default controls that are the arrow keys block the controls. Otherwise, drop in the Keyboard object and add an 'On key pressed' event for that key (not 'Is pressing', the trigger version). This will block the key and make C2 handle it, which should prevent scrolling. You might want to do the same for spacebar which is page-down in some browsers.

  • Hi!

    I'm having the same problem with my game but only in the Scirra arcade.

    It works fine if hosted.

    Any ideas?

    Scirra arcade

    Hosted version

  • UPDATE: I tried using blank events with "when arrow pressed" but is still not working. I tried embeding the code (given in the arcade) into a scrolling website and it works fine. The problem is with the scirra arcade webpage.

    There's something i'm missing here?

    The problem is I didn't manage to find a way to delete my game in the arcade so anyone who may step into it will shut it down in seconds and that's bad publicity.

  • I have had this issue as well. The "Simple" solution of adding events for the buttons doesn't seem to work, especially since I am using the spacebar for some actions, and they still cause scrolling issues.

    Any progress on how to fix this?

    If not I have a sort of work around. My test project is self hosted, so I have complete control of the page it is on. I simply removed anything that would cause the page to be too tall (ie taller than the average browser viewport height).

    I have a comment form on my page, and I solved this problem by giving it a fixed position, and having it slide out when the user hovers over the comments section with their mouse.

    Have a look:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The user must click inside the game before it will get keyboard input. Then, in addition to that, you need the empty 'On key pressed' events. AFAIK this is working for a number of games on the Arcade - if it's not working for you could you share your .capx?

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