-
Notifications
You must be signed in to change notification settings - Fork 3
/
key-tester.html
43 lines (39 loc) · 1.14 KB
/
key-tester.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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>KeyboardEvent key standardiser shim tester</title>
<meta name="description" content="KeyboardEvent key standardiser shim tester">
<meta name="author" content="Nik Paro">
<style>
th, td {
padding: 8px;
min-width: 100px;
text-align: left;
}
</style>
<!--[if lt IE 9]>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<table id="table">
<tr>
<th>Event type</th>
<th>Native key</th>
<th>Standard key</th>
</tr>
</table>
<script>
var table = document.getElementById('table');
var nativeKey = Object.getOwnPropertyDescriptor(KeyboardEvent.prototype, 'key');
document.addEventListener('keydown', function(event) {
event.preventDefault();
var row = document.createElement('tr');
row.innerHTML = '<td>'+event.type+'</td>' + '<td>"'+nativeKey.get.call(event)+'"</td>' + '<td>"'+event.key+'"</td>'
table.insertBefore(row, table.children[1]);
});
</script>
<script src="dist/index.js"></script>
</body>
</html>