How do I bind simultaneous events to selector in jQuery?
I don’t mean how to catch EITHER click or hover on some element, but how to catch two events under condition that BOTH of them occur simultaneously. For example, mouseover and keydown, or click and keydown, like shift+click etc.
Thanks in advance.
Detecting shift + click is easy: Check the
shiftKeyproperty of theeventobject.Checking a pressed key + mouse event (simultaneously), on the other hand…:
event.keyCodeorevent.whichin a variablemousedownevent, which checks the last remembered keyCode, if existent, and execute the relevant code, if applicable.For a full code which handles multiple events (two keydown events, in the example), see my previous answer.