Python: Detect keypress msvcrt.kbhit() on non-focused windows

if msvcrt.kbhit():
   key = msvcrt.getch()
   print(key)
else:
   print('No key pressed')

works perfectly fine (on Windows, of course) but only as long as the cmd is focused. How do I collect keypress outside the terminal?

Note: Non-blocking keylog: Key Down of a keystroke should be recorded only for that moment at which code gets executed, none if not, as opposed to waiting for keypress.