Reputation: 2909
I am trying to capture event if suppose key H is pressed and mouse is moving over some div.
KeyPressed
and mouseMoving
both have to be true.
https://jsfiddle.net/bababalcksheep/1Loeh2pn/
Code:
$('#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');
}
});
Upvotes: 0
Views: 78
Reputation: 666
This may helpful for you.
https://jsfiddle.net/1Loeh2pn/3/
$(function() {
$("#header").hover(function() {
$(document).keydown(function(e) {
if(e.which == 72){
console.log('H')
}
});
});
});
Upvotes: 1