Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

simple input for games javascript

document.body.addEventListener("keydown", function (e) {
  switch (e.key) {
    case ' ':
      flappyBird.velocity.y = -jumpPower
      break
    case 'Enter':
      if(!gameStarted){
        gameStarted = true
        render()
      }
      break
    default:
      break
  }
})
 
PREVIOUS NEXT
Tagged: #simple #input #games #javascript
ADD COMMENT
Topic
Name
4+6 =