-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeycode.html
64 lines (64 loc) · 1.82 KB
/
keycode.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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="robots" content="noindex, nofollow" />
<meta name="googlebot" content="noindex, nofollow" />
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link
href="https://fonts.googleapis.com/css2?family=Source+Code+Pro&display=swap"
rel="stylesheet"
/>
<title>List semantics</title>
<style>
html {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
background-color: black;
color: white;
text-align: center;
font-size: 25px;
font-family: "Source Code Pro", monospace;
}
div {
display: flex;
flex-direction: column;
}
</style>
<script>
var userAgent = window.navigator.userAgent;
var platform = window.navigator.platform;
window.document.addEventListener("keydown", function (event) {
window.document.body.innerHTML = `
<h3>Keydown event with UA: ${userAgent}</h3>
<h3>Platform: ${platform}</h3>
<div>
<b>keyCode: ${event.keyCode}</b>
<br>
<b>key: ${event.key}</b>
<br>
<b>code: ${event.code}</b>
<br>
<b>shiftKey: ${event.shiftKey}</b>
</br>
<b>altKey: ${event.altKey}</b>
<br>
<b>ctrlKey: ${event.ctrlKey}</b>
<br>
<b>metaKey: ${event.metaKey}</b>
</div>
`;
});
window.document.addEventListener("contextmenu", function (event) {
window.document.body.innerHTML = `<h3>${event.target}</h3>`;
event.preventDefault();
});
</script>
</head>
<title>Keycode experimentation</title>
<body>
<div>Type here</div>
</body>
</html>