JSFiddle - React, Tailwind, and code Playground
HTML
<div></div>
CSS
div{
height:200px;
background:red;
position:absolute;
left:200px;
}
JavaScript
$(document).keydown(function(e) {
var moveBy;
switch (e.which) {
case 65: // a
moveBy = -10;
break;
case 68: // ds
moveBy = 10;
break;
}
$('div').css('left', function() {
var l = parseInt($(this).css("left"));
$(this).css("left", (l + moveBy) + "px");
});
});