Here's the code:
from playsound import playsound
import keyboard
key_to_sound = {
'1': 'a.wav',
'2': 'b.wav',
'3': 'c.wav',
'4': 'd.wav',
'5': 'e.wav',
'6': 'f.wav',
'7': 'g.wav'
}
while True:
key = keyboard.read_key()
if key == 'num_1':
break # breaks if num1 pressed
elif key in key_to_sound:
playsound(key_to_sound[key])
"@timgeb" helped me make this code, by the way. Is there any way I could make this module play more than one sound at once or do I have to use more complex modules?