Skip to content

Commit 75bdd2b

Browse files
committed
added keyboard check project
1 parent c330399 commit 75bdd2b

File tree

3 files changed

+107
-0
lines changed

3 files changed

+107
-0
lines changed

keyboard_check/index.html

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Check Keyboard</title>
6+
7+
<!-- css -->
8+
<link rel="stylesheet" href="style.css">
9+
10+
</head>
11+
12+
<body id="canvas">
13+
<div >
14+
<div id="userinput"></div>
15+
<h1>press a key</h1>
16+
</div>
17+
18+
<div class="keyData">
19+
</div>
20+
</body>
21+
22+
<!-- js -->
23+
<script src="script.js"></script>
24+
</html>

keyboard_check/script.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
const userinput = document.querySelector('#userinput');
2+
3+
const keyData = document.querySelector('.keyData');
4+
5+
// key detector
6+
window.addEventListener('keydown', (e) => {
7+
userinput.innerHTML = `${e.key === ' ' ? 'Space' : e.key}`;
8+
9+
keyData.innerHTML = `
10+
<table border="">
11+
<tr>
12+
<th>Key</th>
13+
<th>KeyCode</th>
14+
<th>Code</th>
15+
</tr>
16+
<tr>
17+
<td>${e.key === ' ' ? 'Space' : e.key}</td>
18+
<td>${e.keyCode}</td>
19+
<td>${e.code}</td>
20+
</tr>
21+
</table>
22+
`;
23+
24+
});
25+
26+
27+
// screen cleaner
28+
let clear = function (){
29+
userinput.innerHTML = '';
30+
keyData.innerHTML = '';
31+
};
32+
33+
setInterval(clear, 5000)

keyboard_check/style.css

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
*{
2+
margin: 0;
3+
padding: 0;
4+
box-sizing: border-box;
5+
}
6+
7+
body{
8+
background-color: bisque;
9+
font-family: monospace;
10+
}
11+
12+
#canvas{
13+
display: flex;
14+
justify-content: center;
15+
align-items: center;
16+
flex-direction: column;
17+
height: 90vh;
18+
text-align: center;
19+
}
20+
21+
#userinput{
22+
font-size: 3em;
23+
border-bottom: 2px solid black;
24+
margin: 15px;
25+
height: 60px;
26+
}
27+
28+
.keyData{
29+
margin: 1rem;
30+
font-size: large;
31+
}
32+
33+
@media (max-width: 500px) {
34+
#canvas{
35+
display: flex;
36+
justify-content: center;
37+
align-items: center;
38+
flex-direction: column;
39+
font-size: 0.9em;
40+
height: 60vh;
41+
text-align: center;
42+
}
43+
44+
#userinput{
45+
font-size: 3em;
46+
border-bottom: 2px solid black;
47+
margin: 0.5rem;
48+
height: 50px;
49+
}
50+
}

0 commit comments

Comments
 (0)