0
我试图捕获事件,如果按下键'H'并且鼠标正在移动某个div。当某个按键被按下时,jquery捕获mousemove
的keyPressed和mouseMoving都必须是真实的
https://jsfiddle.net/bababalcksheep/1Loeh2pn/
代码:
$('#header').on("mousemove keydown", function(e) {
//only print if key 'H' is pressed and mouse is moving over $('#header')
if (e.type === 'mousemove' && e.which === 72) {
console.log('working');
}
});
我注意到我必须点击div来触发悬停..如预期正常工作 – django