查看完整版本: 鉴别键盘值代码

tension 2007-10-11 17:53

鉴别键盘值代码

[html]<html>
<body bgcolor=0080ff text=black topmargin=90 onselectstart="return false">
<center>
<h4>Press a Button...</h4>
<script>
function keydown()
{
var keycode=event.keyCode
var Realkey=String.fromCharCode(event.keyCode)
showkeycode.value='按键:    '+Realkey+'\nASCII码: '+keycode
document.form1.realkey.value='按键:    '+Realkey
document.form1.code.value='ASCII码: '+keycode
}
document.onkeypress=keydown    //onkeypress事件对应小写字母等,不包含Ctrl、Shift、Caps、Tab
document.onkeydown=keydown     //onkeydown事件对应大写字母等,包含……
</script>
<div style="display:none">
<textarea id=showkeycode readonly style="background:bgColor; border:1 solid black;color:white">
</textarea>
</div>
<form name=form1>
<input name=realkey readonly style="background:bgcolor;color:white;width:70pt;height:15pt;border:1 solid black">
<br>
<input name=code readonly style="background:bgcolor;color:white;width:70pt;height:15pt;border:1 solid black">
</form>
</body>
</html>
[/html]
页: [1]
查看完整版本: 鉴别键盘值代码