Moath Obeidat
Moath Obeidat

Reputation: 1

How do I stop my website from scrolling up and down with the arrow keys when playing games?

I have a problem with my game website. When the user is playing a Flash game that requires the up and down arrow keys, the page scrolls up and down instead of the object in the game. You can check out this problem through this link to my website http://triceragames.net/diving-dennis/. My website based on Wordpress. The left and right arrows work without any problems.

Upvotes: 0

Views: 450

Answers (1)

Rajinikanth
Rajinikanth

Reputation: 359

I recommend that you incorporate JavaScript in your application. Insert this code wherever you want in your HTML:

document.onkeydown = function(evt) {
    evt = evt || window.event;
    var keyCode = evt.keyCode;
    if (keyCode >= 37 && keyCode <= 40) {
        return false;
    }
};

Hope this helps.

Upvotes: 2

Related Questions