When I ran this script from idle it worked just fine
import keyboard
from playsound import playsound
import os
cwd = os.getcwd()
while True:
if keyboard.read_key() == "q":
playsound(cwd + "\sound.wav")
But when I tried running it as a file it wouldn't work, it opens a window, I press "q" and it just closes