This repository has been archived by the owner on Apr 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
72 lines (62 loc) · 1.72 KB
/
index.html
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
<style>
body {
font-family: Arial, Helvetica, sans-serif;
color: white;
font-weight: bold;
display: flex;
flex-direction: column;
align-items: flex-end;
}
.keyWrapper {
display: flex;
justify-content: flex-end;
}
.key {
background-color: rgba(0, 0, 0, 0.8);
border-radius: 20px;
padding: 20px;
margin-bottom: 10px;
display: inline-block;
animation: hide 300ms linear 1000ms;
animation-fill-mode: both;
}
@keyframes hide {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}
</style>
</head>
<body>
<div id="root"></div>
<script src="https://cdn.socket.io/4.1.2/socket.io.min.js" integrity="sha384-toS6mmwu70G0fw54EGlWWeA4z3dyJ+dlXBtSURSKN4vyRFOcxd3Bzjj/AoOwY+Rg" crossorigin="anonymous"></script>
<script>
var socket = io("http://localhost:3000", {
});
var root = document.getElementById("root");
socket.on("keydown", function (data) {
const keyWrapper = document.createElement("div");
keyWrapper.className = "keyWrapper";
const key = document.createElement("div");
keyWrapper.prepend(key);
key.className = "key";
key.id = Date.now();
key.innerText = data;
setTimeout(() => {
key.remove();
}, 2000);
root.prepend(keyWrapper);
});
</script>
</body>
</html>