04/07 15차 자바스크립트 과

Noh Sinyoung·2023년 4월 14일
0

과제

목록 보기
15/27
<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <script>
        document.addEventListener("keydown", function( event ) {
            if (event.key == "w") {
                console.log("앞으로 간다")
            }
            else if (event.key == "s") {
                console.log("뒤로 간다")
            }
            else if (event.key == "a") {
                console.log("왼쪽으로 간다")
            }
            else if (event.key == "d") {
                console.log("오른쪽으로 간다")
            }
        })
    </script>



</body>
</html>

0개의 댓글