<script> document.onkeydown = function(e){ var e = e || window.event; if(e.keyCode == 13){ alert('按下了回车') } } </script>
<input type="text" onkeyup="showKey(event)"> function showKey(e){ e = e || window.event; alert(e.keyCode);//按一个键 显示一个键的keyCode }如果你不关心这个而只关心键盘输入 只要在元素的onkeydown事件中处理你所要干的事就可以了
<html> <head> <script type="text/javascript"> function showWin(e){ var e = e || window.event; if(e.keyCode == 13){ alert('我敲了回车'); } } </script> </head> <body> <input type="button" onkeyup="showWin(event)"/> </body> </html>
document.onkeydown = function(e){
var e = e || window.event;
if(e.keyCode == 13){
alert('按下了回车')
}
}
</script>
function showKey(e){
e = e || window.event;
alert(e.keyCode);//按一个键 显示一个键的keyCode
}如果你不关心这个而只关心键盘输入 只要在元素的onkeydown事件中处理你所要干的事就可以了
<head>
<script type="text/javascript">
function showWin(e){
var e = e || window.event;
if(e.keyCode == 13){
alert('我敲了回车');
}
}
</script>
</head>
<body>
<input type="button" onkeyup="showWin(event)"/>
</body>
</html>
事件属性
<img>标签支持以下事件属性:属性 值 描述 DTD
onabort 脚本 当图像被中断加载时执行脚本 STF
onclick 脚本 在元素区域内单击鼠标(不区分左右键)时执行脚本 STF
ondblclick 脚本 在元素区域内双击鼠标(不区分左右键)时执行脚本 STF
onmousedown 脚本 在元素区域内按下鼠标键(不区分左右键)时执行脚本 STF
onmousemove 脚本 当鼠标指针在元素区域内移动时执行脚本 STF
onmouseout 脚本 当鼠标指针移出元素区域时执行脚本 STF
onmouseover 脚本 当鼠标指针移入元素区域时执行脚本 STF
onmouseup 脚本 在元素区域内松开鼠标键(不区分左右键)时执行脚本 STF
onkeydown 脚本 按下一个键时执行脚本 STF
onkeypress 脚本 按下并松开一个键时执行脚本 STF
onkeyup 脚本 松开一个键时执行脚本 STF 图片不支持onkeyup事件~·
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head><body>
<input type="image" src="aa.jpg" onkeydown="showWin(event)" />
<script>
function showWin(e){
var e = e || window.event;
if(e.keyCode == 13){
alert('我敲了回车');
}
}</script>
</body>
</html>楼主是这意思?
<input type=submit name=submit1 AccessKey=m value="确定[M]">
Alt+m即可触发。