JSFiddle - React, Tailwind, and code Playground
HTML
<div id='div'></div>
CSS
#div {
background-color: red;
width: 100px;
height: 100px;
position: absolute;
left: 0;
top: 0;
display: inline-block;
}
JavaScript
window.onkeydown = function (e) {
switch (e.which) {
case 37:
document.getElementById('div').style.left = document.getElementById('div').style.left - 10 + 'px'
break;
}
}