开发者

Localising key combination detection to specific active parts of DOM

开发者 https://www.devze.com 2023-03-05 08:44 出处:网络
I need to detect keystroke c开发者_JAVA技巧ombinations in one active (focused) element. However when I have focus on another element and the same keystrokes are pressed, the action shouldn\'t be fired

I need to detect keystroke c开发者_JAVA技巧ombinations in one active (focused) element. However when I have focus on another element and the same keystrokes are pressed, the action shouldn't be fired.

I seem to have trouble doing this. Any help will be appreciated.

Thanks.


You could check out my jQuery plugin that would allow you to do this by selecting the element then picking the key like:

$('input').jkey('alt+a',function(){
  console.log('You pressed alt+a!');
})

Docs: http://oscargodson.com/labs/jkey/

Source: https://github.com/oscargodson/jkey

0

精彩评论

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