diff --git a/index.html b/index.html index 97a5468..889022f 100644 --- a/index.html +++ b/index.html @@ -16,6 +16,10 @@
+ + + +
diff --git a/listening.js b/listening.js index eb6885e..8bd647a 100644 --- a/listening.js +++ b/listening.js @@ -1,4 +1,14 @@ console.log("test") const listener = document.getElementById("listener") -listener.addEventListener("keypress", (event) => console.log(event.key)) -/* document.addEventListener("keypress", (event) => console.log(event.key)) */ \ No newline at end of file +listener.addEventListener("keypress", (e) => { + if (e.key == "w" || e.key == "a" || e.key == "s" || e.key == "d") { + event.preventDefault(); + const id = e.key + document.getElementById('w').click(); + clicked(id) + }}) +/* document.addEventListener("keypress", (event) => console.log(event.key)) */ + +function clicked(id) { + console.log(id) +} \ No newline at end of file