<body
onkeypress="log(eventInfo(event))"
onkeydown="log(eventInfo(event))"
onkeyup="log(eventInfo(event))">
<p>Test that arrow keys do not dispatch keypress events even if there is no default handler.</p>
<p>To test manually, press arrow keys and verify that no keypress events are logged.</p>
<div id="log"></div>
<script>
function log(msg) {
document.getElementById("log").innerHTML+= msg + "<br />";
}
function locationName(code) {
switch (code) {
case 0:
return "DOM_KEY_LOCATION_STANDARD";
case 1:
return "DOM_KEY_LOCATION_LEFT";
case 2:
return "DOM_KEY_LOCATION_RIGHT";
case 3:
return "DOM_KEY_LOCATION_NUMPAD";
default:
return code.toString();
}
}
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
+ '. Value: "' + target.value + '".';
else if (event.type == "keydown" || event.type == "keypress" || event.type == "keyup")
return (where ? "(" + where + ") " : "") + target.tagName
+ (target.tagName == "INPUT" ? " " + target.type : "")
+ " - " + event.type
+ ' - ' + [event.ctrlKey, event.altKey, event.shiftKey, event.metaKey]
+ ' - ' + event.key
+ ' - ' + (event.location === undefined ? "undefined" : locationName(event.location))
+ ' - ' + event.keyCode
+ ' - ' + event.charCode;
} catch (ex) {
alert(ex);
}
}
log("target - type - " + ["ctrlKey", "altKey", "shiftKey", "metaKey"]
+ ' - ' + "key"
+ ' - ' + "location"
+ ' - ' + "keyCode"
+ ' - ' + "charCode");
if (window.testRunner) {
testRunner.dumpAsText();
eventSender.keyDown("ArrowLeft", []);
}
</script>
</body>