javascript - How to detect a keypress AND a mouseover at the same time -


okay can detect mouseover using .on('mouseover')

and can detect keypresses using

$(document).keypress(function(e) {         console.log(e.which); } 

but how detect image mouse hovering on when press button?

the idea able delete image pressing d while hovering on it. ideas ?

you can toggle class or data-attribute shows 1 being hovered

$('img').hover(function(){    $(this).toggleclass('active'); // if hovered has class active }); $(document).keypress(function(e) {         if(e.which == 100){        $('.active').remove(); // if d pressed remove active image     } }); 

fiddle


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -