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

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -