javascript knowing when space is pressed
// event = keyup or keydown
document.addEventListener('keyup', event => {
if (event.code === 'Space') {
console.log('Space pressed'); //whatever you want to do when space is pressed
}
})
//don't forget to upvote answers that help you !document.body.onkeyup = function(e){
if(e.keyCode == 32){
//your code
}
}
Also in JavaScript:
- cjs.js
- nodejs fs delete file
- set a variable in express.js
- javascript math min array
- Your global Angular CLI version (11.0.2) is greater than your local version
- color text react native
- js for of loop
- how to convert char to number in js
- javascript json string
- js array contains
- function isValidWalk(walk)
- javascript foreach object
- js insert in array
- lodash remove element from list
- javascript on submit
- underscore js check boolean value
- electron Uncaught ReferenceError: require is not defined at recorder.js:1
- javascript hide div
- npm generate package-lock.json
- how to iterate through a list in javascript
- python http request post json example
- javascript change image src
- ES6: Use class Syntax to Define a Constructor Function
- check if set has value js