开发者

What is the jQuery key code for Left Shift [duplicate]

开发者 https://www.devze.com 2023-01-16 08:37 出处:网络
This question already has answers here: Can javascript tell the difference between left and right shift key?
This question already has answers here: Can javascript tell the difference between left and right shift key? (4 answers) 开发者_如何学C Closed 8 years ago.

What's the key code for left shift? When I press left shift do something..

Thanks


With JavaScript you can only detect Shift. You can't differentiate left and right shift. Using jQuery:

$("body").keypress(function(event) {
  if (event.shiftKey) {
    //do something here
  }
});


As you can see from this page, the browser does not differentiate from left and right shift. I don't think it's possible.


The only way to know is to ask the user.

So what that means is it not possible with code alone, and not desirable to ask the user.

There is probably a better solution to the problem you think you have.

0

精彩评论

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