How should I handle a Control+Click on an unfocused browser window?

I can’t find a way to detect that a key is down at the time when the window comes into focus: Javascript event listeners fail because they cannot trigger when the window is not in focus.

This results on jarring behavior, as my web page handles standalone clicks very differently from the Control+Click combination.

My idea for how to mitigate this problem is to ignore the click that brings the window into focus, but I’m not entirely happy with this.

(I’m also considering doing nothing about it because I imagine this problem is a lot less common in production, but I’m even less happy with this)