• Resolved nar329

    (@nar329)


    Hello!

    Thank you so much for making this game available! I just tested out the game, and the only issue I’ve encountered at the moment is that clicking the space bar for the first time to start the game can cause an automatic scroll to the bottom of the page.

    I don’t know if there’s a simple fix for this, but for now I will change the instructions so that users click up rather than space.

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Chris David Miles

    (@chrisdavidmiles)

    You’ve got a couple options:

    Option 1 – You could add this JavaScript to the page any time you want to prevent the spacebar from scrolling:

    window.addEventListener('keydown', function(e) {
      if(e.keyCode == 32 && e.target == document.body) {
        e.preventDefault();
      }
    });

    That JavaScript just tells browsers not to scroll when the spacebar is hit.

    Or option 2 – Download and install this plugin to the /wp-content/plugins/ folder of your site. I wrote it in response to this ticket. The plugin just adds that JavaScript to the footer of any page the [dinosaur-plugin] shortcode is present on.

    Hopefully this helps!

    Hi Chris,

    Thanks for this awesome plugin! I have one question.

    is it possible to prevent the game from starting when pressing the spacebar? I have a fill in form right beneath the game on my website, and every time I press the space bar the game will start. But that’s not what I want when someone is filling in the form. Do you have an idea?

    Plugin Author Chris David Miles

    (@chrisdavidmiles)

    @bowas007 there’s not an easy way to do that without modifying the plugin. Here’s a modified version of the game logic you can use: game-logic.min.js

    If you replace the game-logic.min.js file in the plugin on your site with that one, pressing the spacebar won’t start a game.

    The only problem with modifying a plugin this way is that any changes you make like will get overwritten any time you update the plugin. (So if you update this plugin, you will lose this change). In this case that’s probably okay, but perhaps in a future release I’ll explore ways to make it easier for people to drop in their own game files.

    Thread Starter nar329

    (@nar329)

    Thank you for your help! I’m trying out a few different games right now, but this will definitely come in handy, especially if I decide to put more games!

    God bless you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘First Space Bar Click Scrolls to Bottom of Page’ is closed to new replies.