So, I have few image stimuli in my experiment, one keyboard response, in which end routine option is deselected. Now, I have two rectangles (polygon) around two image stims, with opacity 0 by default and one of them must show up depending on the key pressed.
I wrote this code to change opacity to 1, but the code works on any key combinations but those which are specified in the keyboard response:
kb = keyboard.Keyboard()
keys = kb.getKeys(['z', 'm'], waitRelease = False, clear=True)
if 'z' in keys:
core.wait(1)
left_polygon.opacity = 1
elif 'm' in keys:
core.wait(1)
right_polygon.opacity = 1
the keys work (i.e. opacity is changed) only when the key is pressed during fixation and not during the display of images.