Code by which I can prevent scrolling up and down

Closed
amolmali Posts 1 Registration date Friday 21 November 2014 Status Member Last seen 21 November 2014 - 21 Nov 2014 à 01:07
 Blocked Profile - 21 Nov 2014 à 11:48
Hello All. I am a UI Developer and working on one site. There I facing one issue, I need to be lock up and down navigation arrow key on one page. Means I want code by which I can prevent scrolling up and down for keyboard UP and Down navigation Keys.. Is there someone who can assist me in this problem please?

Regards,
Amol Mali

1 response

Blocked Profile
21 Nov 2014 à 11:48
I am going to be honest, I cut and paste this solution from another, untested as of time of posting.

document.addEventListener("keydown", function (e) {
if([37,38,39,40].indexOf(e.keyCode) > -1){
e.preventDefault();
// add in what ever else you want the keys to do if anything!
}
}, false);


The codes are the key codes that is produce when the keys are pressed. If you wish, you can even disable other keys, just find the appropriate codes!

"If you can't soar with the eagles, then don't fly with the flock!" - Oliver Sykes; Bring Me The Horizon