Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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 !
 
PREVIOUS NEXT
Tagged: #javascript #knowing #space #pressed
ADD COMMENT
Topic
Name
4+4 =