键盘和鼠标事件测试
发表于:2007-07-14来源:作者:点击数:
标签:
HTML HEAD TITLE键盘和鼠标事件 测试 /TITLE script language= java script !-- function keyDown(e) { s = ; for(v in event) s += v+=+event[v]+br; view.innerHTML = s; return false; } document.onkeydown=keyDown document.onkeyup=keyDown document.o
<HTML>
<HEAD>
<TITLE>键盘和鼠标事件
测试</TITLE>
<script language="
javascript">
<!--
function keyDown(e) {
s = "";
for(v in event)
s += v+"="+event[v]+"<br>";
view.innerHTML = s;
return false;
}
document.onkeydown=keyDown
document.onkeyup=keyDown
document.onmousedown=keyDown
document.onmouseup=keyDown
document.onmousemove=keyDown
document.onmouseover=keyDown
document.onmouseout=keyDown
document.onkeypress=keyDown
//-->
</script>
</HEAD>
<BODY>
<p>请操作鼠标或键盘</p> <input type=text>
<table border>
<tr><td>123</td></tr>
</table>
<table border>
<tr>
<td colspan=3 id="keyview"> </td>
</tr>
<tr>
<tr>
<td onClick="key(this)" style="cursor=hand;">7</td>
<td onClick="key(this)" style="cursor=hand;">8</td>
<td onClick="key(this)" style="cursor=hand;">9</td>
</tr>
<tr>
<td onClick="key(this)" style="cursor=hand;">4</td>
<td onClick="key(this)" style="cursor=hand;">5</td>
<td onClick="key(this)" style="cursor=hand;">6</td>
</tr>
<tr>
<td onClick="key(this)" style="cursor=hand;">1</td>
<td onClick="key(this)" style="cursor=hand;">2</td>
<td onClick="key(this)" style="cursor=hand;">3</td>
</tr>
<tr>
<td colspan=2 onClick="key(this)" style="cursor=hand;">0</td>
<td onClick="key(this)"> </td>
</tr>
</table>
<span id="view"></span>
</BODY>
</HTML>
原文转自:http://www.ltesting.net