Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Thanks. I was very particular about the palette. Thought as it was minimal colors were important. I did have arrow keys to move but they made the page scroll up and down so I changed to WASD.

(+1)

It looks like your current "key down" code is as follows:

document.body.addEventListener("keydown", function(e) {

  keys[e.keyCode] = true;

});


If you changed the above to something like the following, you'd be able to use arrow keys without scrolling the rest of the page:

document.addEventListener("keydown", function(e) {

  keys[e.which] = true;

  e.preventDefault();

});


The key (no pun intended, ha) there is the "preventDefault()" method; this stops the input from having an effect on the rest of the page after your game has intercepted it. So in the case of using the arrow keys, it will accept the arrow keys as inputs, but will then prevent them from scrolling the rest of the page while your canvas is in focus.


Hope that helps!

(+1)

That's absolutely amazing advice. Hey why not both ;) I'll apply that fix later this evening. Thanks for you help.

(+1)

I've added the arrows as well WASD. Works a treat thank you!

(+1)

Happy to help! :)