Shift + mouseover with jQuery
It is not necessary to store in a variable when the shift key is pressed and released. You can achieve what you are trying to to like this:
$('#selector').mouseover(
function(e){
if (e.shiftKey)
{
console.log("the shift key is pressed");
}
}
);
check this on the keypress event:
$(document).keypress(function (e) {
if(e.shiftKey) {
pressed = true; // pressed is a global varialbe. Be carefull of the scope
}
}
then on the keyup:
$(document).keyup(function(event){
pressed = false;
});
then do:
$("#selector").mouseover(function(e){
if(pressed) {
console.log("the shift key is pressed");
}
});
or the other way around :
$("#selector").mouseover(function(e){
isover = true;
});
and
$(document).keypress(function (e) {
if(e.shiftKey) {
alert("do something")
}
}