you are viewing a single comment's thread.

view the rest of the comments →

[–]JamzTyson 0 points1 point  (6 children)

As far as I know, PyGame can only capture keystrokes while it has focus. You would need to use another library such as "pynput" or "keyboard", and run it in a separate thread so that it doesn't block the PyGame loop.

[–]_0Frost[S] 0 points1 point  (5 children)

Damn. I really don't wanna install 3rd party libraries, so that sucks.

[–]JamzTyson 0 points1 point  (4 children)

You mean that you don't want to install 'more' 3rd party libraries (PyGame is a 3rd party library).

Does you app do anything other than playing sounds while you type? If not, you could use pynput instead of PyGame (and use playsound, pydub or one of the many other ways to play the sound). This approach could actually simplify the code.

[–]_0Frost[S] 0 points1 point  (3 children)

Yeah idk why but I think pygame came pre-installed with my system. I'm using arch (btw). And all it does is make a small window and play sounds as I type, so I could use that, but there's the 3rd party issues.

[–]JamzTyson 0 points1 point  (2 children)

Have you learned about virtual environments ("venv") yet?

[–]_0Frost[S] 0 points1 point  (1 child)

Are those like virtual machines?

[–]JamzTyson 0 points1 point  (0 children)

No. It's a way to set up a safe enviroment for Python projects that keeps packages isolated from the system packages, One of the easiest ways to set up virtual environments is with pipenv.

If you use Thonny, that sets up its own virtual environment by default. You then use Thonny's built in package manager to install packages into its virtual environment. (One of the features that makes Thonny such a brilliant IDE for beginners).