-
Notifications
You must be signed in to change notification settings - Fork 0
/
keycodes.html
115 lines (96 loc) · 3.23 KB
/
keycodes.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<!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>Keycodes</title>
<link rel="stylesheet" type="text/css" href="main.css">
<style>
article {
display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr;
gap: 0.25em;
}
section {
background: light-dark(#f1f1f1, #2b2b33);
border-radius: 7px;
padding: 0.75em;
h3 {
margin: 0;
font-size: 1em;
}
}
h3 {
margin-bottom: 0.2em;
}
</style>
</head>
<body>
<header>
<h1><a href="index.html">Tools</a></h1>
</header>
<main>
<header class="bar">
<h2>Keycodes</h2>
</header>
<noscript>
<p class="placeholder-text">This tool requires Javascript to work.</p>
</noscript>
<article>
<section>
<h3>Key</h3>
<span id="event.key">—</span>
</section>
<section>
<h3>Location</h3>
<span id="event.location">—</span>
</section>
<section>
<h3>Code</h3>
<span id="event.code">—</span>
</section>
<section>
<h3>keyCode</h3>
<span id="event.which">—</span>
</section>
</article>
<h3 hidden id="modifiers">Modifiers</h3>
<kbd hidden id="ctrl">Ctrl</kbd>
<kbd hidden id="shift">Shift</kbd>
<kbd hidden id="alt">Alt</kbd>
<kbd hidden id="meta">Meta</kbd>
<script>
const locations = [
"General keys",
"Left modifiers",
"Right modifiers",
"Numpad"
];
if(navigator.userAgent.includes("Mac")) {
document.getElementById("alt").innerText = "⌥";
document.getElementById("meta").innerText = "⌘";
}
if(navigator.userAgent.includes("Windows")) {
document.getElementById("meta").innerText = "⊞";
}
window.addEventListener("keydown", (event) => {
document.getElementById("event.key").innerText = event.key;
document.getElementById("event.location").innerText = locations[event.location];
document.getElementById("event.code").innerText = event.code;
document.getElementById("event.which").innerText = event.which;
document.getElementById("ctrl").style.display = event.ctrlKey ? "inline" : "none";
document.getElementById("alt").style.display = event.altKey ? "inline" : "none";
document.getElementById("shift").style.display = event.shiftKey ? "inline" : "none";
document.getElementById("meta").style.display = event.metaKey ? "inline" : "none";
if(event.ctrlKey || event.altKey || event.shiftKey || event.metaKey) {
document.getElementById("modifiers").style.display = "block";
} else {
document.getElementById("modifiers").style.display = "none";
}
});
</script>
</main>
<script src="//instant.page/5.2.0" type="module" integrity="sha384-jnZyxPjiipYXnSU0ygqeac2q7CVYMbh84q0uHVRRxEtvFPiQYbXWUorga2aqZJ0z"></script>
</body>
</html>