`
tibaloga
  • 浏览: 876890 次
文章分类
社区版块
存档分类
最新评论

jquery 键盘事件

 
阅读更多
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript" src="jquery-1.6.2.js"></script>




<script type="text/jscript">
$(function(){

$("input:first").keypress(function(event){

var k = event.which; //得到keycode

if( event.which == 122){
alert("我是小z");
}

if( event.which==10){
alert("w是ctrl+enter");
$("form").submit();

}



})
//进入页面默认的第一个表单获得焦距
$("input[type='text']:first").trigger("focus")
//当按下键盘时第2个表单自动获得焦距
$(document).keydown( //没有效果
$("input[type='text']:last").trigger("focus")
)



})





</script>
</head>


<body>
<input type="text" />
<form method="post" action="http://www.baidu.com">
<input type="submit" value="tijiao"/>

</form>
<input type="text" />
</body>
</html>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics