JSFiddle - React, Tailwind, and code Playground

HTML

<div class="player">
</div>

CSS

.player {
        position: absolute;
        background-color: #000;
        width: 5px;
        height: 70px;
        margin: 20px 0 0 10px;
        padding: 0 0 0 0;
    }

JavaScript

var playerPosition = 0;

window.onkeyup = function(e) {
    var key = e.keyCode ? e.keyCode : e.which;

    if(key = 38) {
        playerPosition += 10;
    } else if(key = 40) {
        playerPosition -= 10;
    }

    var players = document.getElementsByClassName('player');
    for(var i = 0; i < players.length; i++)
        players[i].style.marginTop = playerPosition+".px";

 }