Is there a way I can monitor keyboard input if the Qt window is not active? In addition to regular alphanumeric keys, I want to passively monitor function keys and control characters.

I prefer Python, but I'll do it in C++ if I need to. I used pynput to capture keys in PyQt, but it has issues identifying some control keys (like ctrl-. or ctrl-,) which I need.

I know Qt has built in capturing for its active windows but what about across all windows (without interfering with the intended action of those keys)?