在你的body里面订购事件 on
Key
Down = 处理函数,然后在处理函数中判断
event. key Code如果是 13 ,那么按下的是enter,调用你button的onclick的事件处理函数,否则就什么也不做。
我写了个简单的例子:
<html>
<head>
<title> key </title>
<body onKeyDown = "_b()">
<input type = "button" onclick = "_a()" value = "click"/>
<script>
function _a()
{
alert("按钮被点击");
}
function _b()
{
if(event.keyCode ==13)
_a();
}
</script>
</body>
</html>
event. key Code如果是 13 ,那么按下的是enter,调用你button的onclick的事件处理函数,否则就什么也不做。
我写了个简单的例子:
<html>
<head>
<title> key </title>
<body onKeyDown = "_b()">
<input type = "button" onclick = "_a()" value = "click"/>
<script>
function _a()
{
alert("按钮被点击");
}
function _b()
{
if(event.keyCode ==13)
_a();
}
</script>
</body>
</html>