How do I stop SPACE from scrolling down?

0 favourites
  • 6 posts
From the Asset Store
Classic style beat'em up template. Punch & Kick foes across the screen.
  • Hello,

    I have a typing game and I used a "Text" object to display what the user is typing.

    I hardcoded all the letters, numbers, and special buttons like Backspace, Shift, Space, Enter - that's because when you hit one of those an effect will occur.

    The problem is that when I export the game and I upload it to a site when the user hits SPACE, the browser will scroll down.

    How can I solve this problem?

    Thank you! :)

  • Full screen?

  • Full screen?

    Unfortunately, this is not a solution because the game will be published on different platforms via iframe. So, the game will be played in 960x540 (for example) 90% of the time.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Try running the following script on start of your first layout:

    window.addEventListener('keydown', event => {
     if ([' '].includes(event.key)) {
     event.preventDefault();
     }
    });
    
    
  • Try running the following script on start of your first layout:

    > 
    window.addEventListener('keydown', event => {
    if ([' '].includes(event.key)) {
    event.preventDefault();
    }
    });
    
    

    I'm out of the city for the moment, but I will get to it in 1-2 days. I will come back with updates. Thank you for the suggestion!

  • Try running the following script on start of your first layout:

    > 
    window.addEventListener('keydown', event => {
    if ([' '].includes(event.key)) {
    event.preventDefault();
    }
    });
    
    

    dop2000, it seems that your code is working! :)

    Thank you very much for your help!

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