I'm trying to detect whether the shift key is being pressed while the cursor is moved over a particular element. The function fires, but only after I click on another element first. Is there some way to work around this? I've tried setting focus to both the document and element, and tried creating a pseudo-click function but so far nothing has worked.
For example, the following code works only after I click another element on the page:
$("#selector").mouseover(function(e){
if(e.shiftKey) {
console.log("the shift key is pressed");
}
});
Thanks in advance for any information.