Skip to content

Commit ff8ff16

Browse files
committed
KeyboardState.html add logging of keys
1 parent 8f2bf15 commit ff8ff16

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

KeyboardState.html

+10
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@
3737
keyStateDict[GetCodeFor(event)] = description;
3838
displayKeyState();
3939
}
40+
function logEvent(description)
41+
{
42+
var logDiv = document.getElementById("keyLog");
43+
var entry = document.createElement("div");
44+
entry.innerText = description;
45+
logDiv.insertBefore(entry, logDiv.firstChild)
46+
}
4047
function GetCodeFor(e)
4148
{
4249
if ((e.charCode) && (e.keyCode==0))
@@ -73,6 +80,7 @@
7380
d = GetDescriptionFor(e);
7481
updateInnerHTML("td-keydown", d);
7582
updateKeyState(e, d + " == DOWN");
83+
logEvent(d + " == down");
7684
return false;
7785
}
7886
function MonitorKeyUp(e)
@@ -81,13 +89,15 @@
8189
d = GetDescriptionFor(e);
8290
updateInnerHTML("td-keyup", d);
8391
updateKeyState(e, d + " == up");
92+
logEvent(d + " == up");
8493
return false;
8594
}
8695
function MonitorKeyPress(e)
8796
{
8897
if (!e) e=window.event;
8998
d = GetDescriptionFor(e);
9099
updateInnerHTML("td-keypress", d);
100+
logEvent(d + " == press");
91101
return false;
92102
}
93103

0 commit comments

Comments
 (0)