const container = document.querySelector('.game-container'); const player = document.createElement('div'); player.classList.add('player'); container.appendChild(player); const enemy = document.createElement('div'); enemy.classList.add('enemy'); container.appendChild(enemy); document.addEventListener('keydown', (event) => { if (event.key === 'ArrowLeft') { player.style.left = parseInt(player.style.left, 10) - 10 + 'px'; } else if (event.key === 'ArrowRight') { player.style.left = parseInt(player.style.left, 10) + 10 + 'px'; } });