开发者

Localising key combination detection to specific active parts of DOM

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜