html disable scrolling with keys

Solutions on MaxInterview for html disable scrolling with keys by the best coders in the world

showing results for - "html disable scrolling with keys"
Debora
26 Jun 2016
1<script>
2  /*
3  These lines of code disable the funcionality of the arrow keys and the 
4  space key
5  */
6  window.addEventListener("keydown", (e) => {
7    switch(e.keyCode) {
8      case 32: 
9      case 37: 
10      case 38: 
11      case 39: 
12      case 40:
13        e.preventDefault();
14        break;
15      default:
16        break;
17    }
18  });
19</script>