Code by which I can prevent scrolling up and down

Closed
amolmali Posts 1 Registration date Friday November 21, 2014 Status Member Last seen November 21, 2014 - Nov 21, 2014 at 01:07 AM
 Blocked Profile - Nov 21, 2014 at 11:48 AM
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
Related:

1 response

Blocked Profile
Nov 21, 2014 at 11:48 AM
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
0