JSFiddle - React, Tailwind, and code Playground

by zequez

HTML

<div class="ball"></div>

CSS

.ball {
    position: absolute;
    top: 0px;
    left: 0px;
    height: 50px;
    width: 50px;
    background: black;
    border-radius: 25px;
}

CoffeeScript

ball = document.getElementsByClassName('ball')[0]
console.log ball

y = 0
x = 0
document.body.addEventListener 'keypress', (event)->
  console.log event
    
  y += 5 if event.charCode == 115 # S
    
  console.log 'Moviendo pelota!'
  ball.style.top = y + 'px'
  ball.style.left = x + 'px'