-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
33 lines (26 loc) · 742 Bytes
/
script.js
File metadata and controls
33 lines (26 loc) · 742 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const userinput = document.querySelector('#userinput');
const keyData = document.querySelector('.keyData');
// key detector
window.addEventListener('keydown', (e) => {
userinput.innerHTML = `${e.key === ' ' ? 'Space' : e.key}`;
keyData.innerHTML = `
<table border="">
<tr>
<th>Key</th>
<th>KeyCode</th>
<th>Code</th>
</tr>
<tr>
<td>${e.key === ' ' ? 'Space' : e.key}</td>
<td>${e.keyCode}</td>
<td>${e.code}</td>
</tr>
</table>
`;
});
// screen cleaner
let clear = function (){
userinput.innerHTML = '';
keyData.innerHTML = '';
};
setInterval(clear, 5000)