It's maybe worth noting that ctrl-click
does not have the same behavior on all platforms; even if this worked, it would only work for a subset of users. (The MDN docs contain a fun example of this; they do note which literal button Ctrl
maps to on a mac... but the demo is unusable because ctrl-click triggers a (native, non-browser) context menu, preventing the click event even reaching the demo panel. (For OSX you'd want to look for metaKey
, not ctrlKey
.)
If you reeeeeeeally want to do this, check navigator.platform
first to determine whether to use ctrlKey
or metaKey
(and possibly something else on other platforms than desktop mac or windows, I'm not certain.)
To open new tabs in the background, I believe you can trigger a focus
event on the originating window after the secondary tab/window is opened. (I would strongly recommend against it, though; modifying expected, standard browser behavior is not great UX, and would likely have accessibility implications.)