I would like to detect what modifiers are pressed on startup of my program. So far I haven't found any good libraries or methods for that. What I found are
- WxPython, Tkinter, PyGame, and the like, which can all get the modifier states, but need a GUI for that and I don't want to
- keyboard (https://pypi.org/project/keyboard/), which I didn't look further into because it needs root and I don't want to grant that
- pynput (https://pypi.org/project/pynput/). This comes the closest, however it cannot detect a pressed key or modifier on startup - as far as I see in the documentation, the only provided things are callbacks for keyup and keydown (https://pynput.readthedocs.io/en/latest/keyboard.html#monitoring-the-keyboard), however these are not called when the key is pressed on startup, as well as the Controllers.modifiers (https://pynput.readthedocs.io/en/latest/keyboard.html#pynput.keyboard.Controller.modifiers), however these are not the actual state of the physical keyboard, but rather pynput internals (see this issue: https://github.com/moses-palmer/pynput/issues/20).
I am looking for a way to detect if modifiers are pressed, that works without root, without GUI, and at startup. Any help is greatly appreciated, thanks.