How to display random images from a folder at random time? How to add a keyboard response when an image changes to another?

OS (e.g. Win10): Windows 11 Pro
PsychoPy version (e.g. 1.84.x): PsychoPy 2024 1.3
Standard Standalone? (y/n) If not then what?:
What are you trying to achieve?: The experiment trial is setup in a way that it displays images one by one randomly at random timestamps from a folder. The experiment begins with the first trial. It displays one random image for some random time and changes to another random image. A keyboard response should be made when the image changes. The trial ends and has to be looped. The folder contains N images.

What did you try to make it work?: I worked with 2 images for fixed time. Like one image stays for n seconds and the second image displays and, a keyboard response is made when the second image is displayed.

What specifically went wrong when you tried that?: When I tried to work with 2 images to be random, the images changes only if a keyboard response is made.
Also, I could load the folder which contains N images but couldn’t achieve the keyboard response as I expected.