.getKeys()
is an instantaneous check of the keyboard queue, so it doesn’t usually make sense to call it just once: it needs to be in a loop so that it gets called repeatedly until a response is made.
You should also look into PsychoPy’s own Sound module for opening and playing sounds. At the moment you seem to be operating at a very low level, reading in data continuously. The PsychoPy Sound module lets you operate at a higher level of abstraction: just .play()
the sound and then move on, freeing you up to draw stimuli, check for responses and so on.
You’d be well served by working through some more of the demos available from the demos menu in the Coder view to pick up more of how to do each of these things in a PsychoPy style.