开发者

Capture an Enter Key Pressed anywhere on the page

I need to capture an Enter Key press at any time anywhere on a logon page. It will initiate a logon attempt.

Using jQuery, how would I accomplish this? And w开发者_如何转开发ould I link it to the body tag?


$(document).keypress(function(e) {
  if(e.which == 13) {
    // enter pressed
  }
});


The keydown event is fired when a key is pressed down.
The keypress event is fired when a key is pressed down and that key normally produces a character value.

$(document).keydown( function(event) {
  if (event.which === 13) {
    // login code here
  }
}); 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜