Using an Google Analytics (GA), I use e.preventDefault()
on external links so I can give GA about 100ms to detect the click before leaving the site. This is a common practice, from what I’ve read.
I never use target=_blank
unless I’ve got a gun pointed to my head, and I’ve finally brought around the talking heads to stop using it. GREAT… BUT… using e.preventDefault()
, this also stops the defaults for middle click as well as ctrl+click to open in a new tab should the user choose to.
Now, I found that e.which
being equal to 2
means a middle click, and that’s reliable enough. What I can’t find good info on is detecting a ctrl+click without relying on jQuery’s keydown
– in fact this has to be vanilla JS through and through.
Does anyone have experience with this specifically that’s reliable?