keyboard dom 11
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>replit</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<input placeholder="Move your character" >
<button>click me</button>
<script src="index.js"></script>
</body>
</html>
let inp = document.querySelector("input")
inp.addEventListener("keydown", function(){
if(event.code == "KeyU"){
console.log("ch move fordward")
}
else if(event.code == "KeyD"){
console.log("ch move back")
}
else if(event.code == "KeyA"){
console.log("ch move flet")
}
else if(event.code == "KeyX"){
console.log("ch move flet")
}
})
Comments
Post a Comment