Use globalshortcut only if active app is not using it

I’ve created a tray-based Electron app that allows me to call various scripts regardless of my active application. This is similar to the Services feature of Mac OS.

The issue I’m having, is that if there’s a conflict in key binding between my tray app and my active app, I would like the active app’s binding to take precedence.

The services menu that I’m emulating was able to do this. I’m not sure how this would be done through Electron; how would I check the active application? Even if I deregister the tray app’s binding, I would probably have to send the key event to the active app?

Any suggestions?