-
Notifications
You must be signed in to change notification settings - Fork 6
/
keys-browser.html
86 lines (79 loc) · 2.68 KB
/
keys-browser.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
<!DOCTYPE>
<html>
<head>
<link rel="manifest" href="/manifest-browser.json">
<meta name="viewport" content="width=device-width">
<style>
* {
font-size: x-small;
}
#scroller {
overflow: scroll;
width: 100%;
height: 200px;
}
</style>
<script>
let preventDown = false;
let preventPress = false;
let preventUp = false;
onkeydown = (e) => {
const output = document.getElementById("output");
output.innerHTML += 'DOWN: ' + e.key + ' cancelable[' + e.cancelable + ']';
if (preventDown) {
output.innerHTML += ' #PREVENTED#';
e.preventDefault();
}
output.innerHTML += "<br>";
document.getElementById('scroller').scrollTop = 100000;
}
onkeypress = (e) => {
const output = document.getElementById("output");
output.innerHTML += 'PRESS: ' + e.key + ' cancelable[' + e.cancelable + ']';
if (preventPress) {
output.innerHTML += ' #PREVENTED#';
e.preventDefault();
}
output.innerHTML += "<br>";
document.getElementById('scroller').scrollTop = 100000;
}
onkeyup = (e) => {
const output = document.getElementById("output");
output.innerHTML += 'UP: ' + e.key + ' cancelable[' + e.cancelable + ']';
if (preventUp) {
output.innerHTML += ' #PREVENTED#';
e.preventDefault();
}
output.innerHTML += "<hr>";
document.getElementById('scroller').scrollTop = 100000;
}
onload = () => {
let formHeight = document.getElementById('f').clientHeight;
document.getElementById('scroller').style.height = (window.innerHeight - formHeight- 26) + "px";
preventDown = document.getElementById("boxDown").checked;
preventPress = document.getElementById("boxPress").checked;
preventUp = document.getElementById("boxUp").checked;
}
function togglePreventDown() {
preventDown = !preventDown;
}
function togglePreventPress() {
preventPress = !preventPress;
}
function togglePreventUp() {
preventUp = !preventUp;
}
</script>
</head>
<body>
<form id="f">
<input id="boxDown" type="checkbox" name="prevent" value="prevent" onclick="togglePreventDown();"> prevent down<br>
<input id="boxPress" type="checkbox" name="prevent" value="prevent" onclick="togglePreventPress();"> prevent press<br>
<input id="boxUp" type="checkbox" name="prevent" value="prevent" onclick="togglePreventUp();"> prevent up<br>
</form>
<div id="scroller">
<div id="output">
</div>
</div>
</body>
</html>