<!DOCTYPE>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>Mouse and Special Key</title>
<script>
function MouseClick(event)
{
// event.button: 0, 1, 2
alert("You pressed button: " + event.button);
}
var oldstr = 0;
function WhichKey(event)
{
str = "Key pressed ("+event.keyCode+") :";
(event.keyCode == 38 ? str += " UP " : "" );
(event.keyCode == 40 ? str += " DOWN " : "" );
(event.keyCode == 37 ? str += " LEFT " : "" );
(event.keyCode == 39 ? str += " RIGHT " : "" );
(event.keyCode == 16 ? str += " SHIFT " : "" );
(event.keyCode == 17 ? str += " CTRL " : "" );
(event.keyCode == 18 ? str += " ALT " : "" );
(event.keyCode == 27 ? str += " ESC " : "" );
(event.keyCode == 9 ? str += " TAB " : "" );
(event.keyCode == 13 ? str += " ENTER " : "" );
(event.keyCode == 113 ? str += " F2 " : "" );
(event.keyCode == 93 ? str += " WINDOW " : "" );
if ((event.shiftKey !== true) && (event.keyCode == 45)) str += " INS ";
if ((event.shiftKey === true) && (event.keyCode == 45)) str += " SHIFT+INS ";
if ((event.shiftKey === true) && (event.keyCode == 46)) str += " SHIFT+DEL ";
if ((event.shiftKey === true) && (event.keyCode == 37)) str += " SHIFT+LEFT ";
if ((event.shiftKey === true) && (event.keyCode == 39)) str += " SHIFT+RIGHT ";
if (oldstr != str) {
document.getElementById("list").innerHTML += str+"<br>";
oldstr = str;
}
}
function MouseWheel()
{
document.getElementById("list").innerHTML += "Mouse Wheell <br>";
}
</script>
</head>
<body onkeydown="WhichKey(event); return false;">
<div onmousedown="MouseClick(event)"
onmousewheel="MouseWheel()"
style="background-color: #DFDFFF; font-size: xx-large; line-height: 150%">
Checks for the following:
<br>Mouse: 0 = left mouse button 1 = middle mouse button 2 = right mouse button<br>
Key Pressed: All special keys.
</div>
<div id="list"></div>
</body>
</html>