<html>
<head>
<script>
function keyLocationToText(location)
{
switch (location) {
case KeyboardEvent.DOM_KEY_LOCATION_STANDARD:
return "DOM_KEY_LOCATION_STANDARD";
case KeyboardEvent.DOM_KEY_LOCATION_LEFT:
return "DOM_KEY_LOCATION_LEFT";
case KeyboardEvent.DOM_KEY_LOCATION_RIGHT:
return "DOM_KEY_LOCATION_RIGHT";
case KeyboardEvent.DOM_KEY_LOCATION_NUMPAD:
return "DOM_KEY_LOCATION_NUMPAD";
default:
return "" + location
}
}
function keyevent(event) {
var p = document.createElement("p");
p.appendChild(document.createTextNode(event.type + " - key: " + event.key + "@" + keyLocationToText(event.location) + " (keyCode/charCode: " + event.keyCode + "/" + event.charCode + ")" + " modifiers: " + event.ctrlKey + "," + event.altKey + "," + event.shiftKey + "," + event.metaKey));
document.getElementById("result").appendChild(p);
}
function init() {
var input = document.getElementById("testinput");
input.addEventListener("keydown", keyevent, true);
input.addEventListener("keypress", keyevent, true);
input.addEventListener("keyup", keyevent, true);
if (window.testRunner)
testRunner.dumpAsText();
input.focus();
if (window.eventSender) {
eventSender.keyDown("\t");
eventSender.keyDown("\t", new Array("shiftKey"));
}
}
</script>
</head>
<body onload="init()">
<form>
<input type="text" size="50" id="testinput" />
<input type="text" size="50" />
</form>
<p>This tests that DOMKeyboardEvents are created correctly in the JavaScript API.</p>
<div id="result"></div>
</body>
</html>