Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript prevent space from scrolling

window.addEventListener('keydown', function(e) {
  if(e.keyCode == 32 && e.target == document.body) {
    e.preventDefault();
  }
});
Comment

prevent spacebar for scrolling in javascript

window.addEventListener('keydown', (e) => {  
  if (e.keyCode === 32 && e.target === document.body) {  
    e.preventDefault();  
  }  
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: loop key in object 
Javascript :: auto increment schema mongoose id 
Javascript :: converting json to javascript object 
Javascript :: add jquery cdn 
Javascript :: exit extension from chrome javascript 
Javascript :: jq object to dom object convert 
Javascript :: define default no cache axios headers 
Javascript :: clear session storage on refresh 
Javascript :: remove the items in array which are present in another javascript 
Javascript :: eliminar el ultimo caracter de un string javascript 
Javascript :: jest console.log 
Javascript :: Javascript switch case code format 
Javascript :: vue add script tags and link tags 
Javascript :: react router history push parameter 
Javascript :: infinite for loop javascript 
Javascript :: async storage has been extracted from react-native core 
Javascript :: electron file association 
Javascript :: javascript parsefloat() method 
Javascript :: $(getJson) returning error 
Javascript :: console log object js 
Javascript :: sort array based on another array 
Javascript :: change href with jquery 
Javascript :: how to reverse a string in javascript 
Javascript :: check if string is datestring javascript 
Javascript :: load script defer 
Javascript :: js code stars 
Javascript :: convertir seconde 
Javascript :: devtools failed to load sourcemap when debugging react native 
Javascript :: UpperCase every first letter in each word in str 
Javascript :: express body-parser is depreciated 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =