html5的键盘事件,主要的有三个:

onkeydown     当按下按键时运行脚本

onkeypress     当按下并松开按键时运行脚本

onkeyup         当松开按键时运行脚本
<!DOCTYPE HTML>
<html>
<body>
<script type="text/javascript">
function check(){
  alert("aaa");
}
</script>
<form action="a.php" method="post">
<input type="email" name="e" onkeydown="check();"/><br />
<input type="submit" value="send" />
</form>
</body>
</html>
onkeydown="check();"这个表示当按下键盘上的任意一个键时都会执行check()函数,
<!DOCTYPE HTML>
<html>
<body>
<script type="text/javascript">
function check(){
  alert("aaa");
}
</script>
<form action="a.php" method="post">
<input type="email" name="e" onkeydown="check();"/><br />
<input type="submit" value="send" />
</form>
</body>
</html>
onkeydown="check();"这个表示当按下键盘上的任意一个键时都会执行check()函数,

来源:

http://jingyan.baidu.com/article/6fb756ec90071f241958fb5a.html

相关文章:

  • 2021-10-07
  • 2021-08-08
  • 2021-12-09
  • 2021-12-09
  • 2022-12-23
  • 2021-11-27
猜你喜欢
  • 2022-12-23
  • 2021-12-09
  • 2021-11-27
相关资源
相似解决方案