How do I override arrow Up

0 favourites
  • 9 posts
From the Asset Store
Full game Construct 2 and Construct 3 to post on Google Play
  • Hello,

    I have a game that does jump on arrow up, but arrow up is also default key in browsers for moving content up. And every time user presses arrow up the game character does jump but it also moves complete content of the page up.

    Is there a way to disable browser reacting to this and leave arrow up only to the game.

    Thank you.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Think you have a better chance of checking out with the browser you are using if it can be done there. I dont think it have anything to do with C2, otherwise you can use the nodeweb kit one.

  • This is the game so it will be in many different browsers. Shouldn't Construct2 override arrow up at least it says like that in documentation.

  • [quote:1q14pw30]This is the game so it will be in many different browsers. Shouldn't Construct2 override arrow up at least it says like that in documentation.

    I cant find in the documentation where it says that? but i get your point. I dont know how you can do it, doesnt seem to be any setting for it from what i can see

  • This shouldn't happen. This is happening when you preview on browser, or after you upload the game on ftp?

  • Ok here is the solution.

    If you want to disable key for good, you put the On Key Event but with empty action.

    This happens when you have a key that you use in game but not every time. For example i have motorbike that jumps only when its on ground. So users can press up to jump if in air but it will not do jumps because motorbike is not grounded.

    I expected Construct2 to catch this and not let it to browser because i have event OnKeyDown but just with additional check is motorbike grounded. Looks like Construct2 catches key up, checks is grounded if not it actually releases event to browser. Not exactly sure is this what's happening but it looks like it is.

    It's important that you can go around this by adding event OnKeyDown that does nothing so it catches it every time. After that event you can make your own logic with other one.

    Hope this helps.

  • I to have a game with OnKeyDown...I'm having the same problem except only in Firefox. In Chrome the screen doesn't bounce around at all. but Firefox moves up (just a little bit) with up arrow and the same for the down arrow. It's very annoying.

    list3ner seems like a decent work around, but that can't be the way to solve it.

    Anyone else know?

  • Adding an empty event to block the browser default action is documented behavior. It only works with the 'On pressed' triggers, not the 'Is key down' conditions.

  • Ashley thanks, I added 3 Events: On Space Pressed, On Up Arrow Pressed, On Down Pressed. That fixed it.

    I guess I was worried it was making the code do unnecessary checks, but then I realized I already have code checking for space bar presses, but since there's an Action that is triggered it must somehow not block the rest? I'm happy it works but still a little foggy on why it works.

    Yaay, I can use Firefox again..

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