Problem with getKeys

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.

I remember there were some issues with opacity in online exps - I do not know if these still exist.
Try having the rectangles the same colour as the background (thus emulating opacity = 0) and then change their colours to the colour of your choice (thus emulating opacity = 1)

Tried, not working…

I have figured the issue out by myself, had to move up the polygon and code frames, now it works. Timing issue is there, but that can be fixed with the design part.