blob: f06fd13457962dd952908c95cc6886fc96277e4d [file] [log] [blame]
<p>To test manually, press keys and compare results to other browsers.</p>
<input type="button" value="Input"
onclick="log(eventInfo(event));"
onmousedown="log(eventInfo(event));"
onmouseup="log(eventInfo(event));"
onkeypress="log(eventInfo(event));"
onkeydown="log(eventInfo(event));"
onkeyup="log(eventInfo(event));">
</input>
<div id="log"></div>
<script>
function log(msg) {
document.getElementById("log").innerHTML+= msg + "<br />";
}
function eventInfo(event, where) {
try {
if (!event)
event = window.event;
target = event.srcElement ? event.srcElement : event.target;
if (event.type == "textInput")
return (where ? "(" + where + ") " : "") + target.tagName + " - " + event.type + " - " + event.data;
else if (event.type == "keydown" || event.type == "keypress" || event.type == "keyup")
return (where ? "(" + where + ") " : "") + target.tagName + " - " + event.type
+ ' - ' + [event.ctrlKey, event.altKey, event.shiftKey, event.metaKey]
+ ' - ' + event.key
+ ' - ' + event.code
+ ' - ' + event.keyIdentifier
+ ' - ' + event.keyCode
+ ' - ' + event.charCode
+ ' - ' + event.which;
else if (event.type == "mousedown" || event.type == "click" || event.type == "mouseup")
return (where ? "(" + where + ") " : "") + target.tagName + " - " + event.type;
} catch (ex) {
alert(ex);
}
}
log("target - type - " + ["ctrlKey", "altKey", "shiftKey", "metaKey"]
+ ' - ' + "key"
+ ' - ' + "code"
+ ' - ' + "keyIdentifier"
+ ' - ' + "keyCode"
+ ' - ' + "charCode"
+ ' - ' + "which");
if (document.getElementsByTagName("input")[0].addEventListener)
document.getElementsByTagName("input")[0].addEventListener('textInput', function(e) {log(eventInfo(e));}, false);
document.getElementsByTagName("input")[0].focus();
if (window.testRunner) {
testRunner.dumpAsText();
log("Space:");
eventSender.keyDown(" ", []);
log("Enter:");
eventSender.keyDown("\r", []);
log("A:");
eventSender.keyDown("A", []);
}
</script>