http://oraclestudy.iteye.com/blog/1232946
<html>
<head>
<title></title>
<script type="text/javascript">
document.onkeydown=function(e)
{
//debugger;
//获得键盘按下事件,支持ie,ff,google,safari,opera
var loginae=(typeof event!='undefined')?window.event:e;
if(loginae.keyCode==13&&document.activeElement.id=="txtC")
{
//你的操作
alert('按什么按?');
}
}
</script>
</head>
<body>
<input type="text" id="txtC" />
</body>
</html>
此博客展示了如何在HTML中使用JavaScript监听键盘事件,并在按下特定键时执行操作。

被折叠的 条评论
为什么被折叠?



