-
Notifications
You must be signed in to change notification settings - Fork 15
/
index.html
37 lines (36 loc) · 1.23 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>keyboardevent-key-polyfill demo</title>
<style>
body { font: 2em monospace; }
.main { margin: 2em 10%; }
p { color: #333; }
code { background: whitesmoke; white-space: pre; padding: 0.1em 0.5em; }
.projectName { background: yellow; color: #666; display: inline; font-size: 1.5em; font-weight: 300; padding: .2em .4em; }
.projectName b { color: #000; font-weight: 600; }
.directions { color: #999; font-style: italic; margin-top: 1.5em; }
</style>
</head>
<body>
<main id="main" class="main">
<h1 class="projectName"><b>keyboardevent-key-polyfill</b> demo</h1>
<p class="directions">Press any key</p>
</main>
<footer id="footer"></footer>
<script src="index.js"></script>
<script>
(function () {
window.keyboardeventKeyPolyfill.polyfill();
// Don't try `keypress`.
document.body.addEventListener('keydown', function (e) {
var msg = (e.which || e.keyCode) + ' → ' + '<code>' + e.key + '</code>';
console.log(msg);
main.innerHTML += '<p>' + msg + '</p>';
footer.scrollIntoView();
});
})();
</script>
</body>
</html>