URL of experiment:
Description of the problem:
Hello, I need your helps.
I am making a code in the ‘code’ component to get mouse click while participants pressing a certain key.
In specific, ‘s’, ‘d’, and ‘space’ keys are allowed, and participants are allowed to click on the image only when they are pressing ‘s’ and ‘d’. When the key is released, mouse clicks are blocked. When the key is pressed again, they can click on the image again. When ‘space’ key is pressed, the trial ends. Multiple mouse clicks are allowed while pressing a key. Multiple key presses and releases are also allowed in a trial unless ‘space’ key is pressed. How should I structure my code?
Current structure of my code is:
(Below is not written in python language
#if 's' or 'd'_is_pressed:
# check if mouse is clicked in a valid clickable area
# if mouse is clicked in a valid clickable area:
# if key_pressed is 's':
# do A
# if key_pressed is 'd':
# do B
# if mouse is not clicked in a valid clickable area:
# ignore the mouse click
#
#elif 'space' key is pressed:
# continueRoutine = False
This is my general structure in ‘Each Frame’ tab, but I have no idea how I can check if key is being pressed. Can you help me with this issue?