-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
20 lines (16 loc) · 773 Bytes
/
app.js
File metadata and controls
20 lines (16 loc) · 773 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
const startGame = document.getElementById("startGame");
const charTitle = document.getElementById("charTitle");
const nameTitle = document.getElementById("nameTitle");
const keyCode = document.getElementById("keyCode");
const keyChar = document.getElementById("keyChar");
const keyName = document.getElementById("keyName");
const printKey = (e) => {
startGame.innerText !== "" && (startGame.innerText = "");
charTitle.innerHTML !== "Key: " && (charTitle.innerHTML = "Key: ");
nameTitle.innerHTML !== "KeyName: " &&
(nameTitle.innerHTML = "KeyName: ");
keyCode.innerText = e.keyCode;
keyChar.innerText = e.key === " " ? "Space" : e.key;
keyName.innerText = e.code;
};
window.addEventListener("keydown", printKey);