# The two participants perform an experiment at the same time

**URL:** <https://discourse.psychopy.org/t/the-two-participants-perform-an-experiment-at-the-same-time/22191>\
**Category:** Builder\
**Created:** [April 10, 2021, 1:36pm UTC](https://discourse.psychopy.org/t/the-two-participants-perform-an-experiment-at-the-same-time/22191 "2021-04-10T13:36:54Z")\
**Posts on this page:** 4\
**Page:** 2

<div class="post-metadata">

**Author:** ![fazel\_amirvahedi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/fazel_amirvahedi/32/10785_2.png) [@fazel\_amirvahedi](https://discourse.psychopy.org/u/fazel_amirvahedi)\
**Post date:** [June 10, 2021, 1:37pm UTC](https://discourse.psychopy.org/t/the-two-participants-perform-an-experiment-at-the-same-time/22191/21 "2021-06-10T13:37:22Z")

</div>

Yes, both subjects do two tasks at the same time, and on a computer whose screen is extended, each screen shows one of the tasks.  
Two keyboards are connected to the computer, which is actually known as a single keyboard by Psychopy.  
In the first trial, there is no problem to start at the same time, because the first subject must press ‘y’ and the second subject must press ‘n’, but during the task, when, for example, the first subject finishes its trial earlier, press the ‘y’ button before the second subject trial ends and waits for ‘n’ that the second subject presses the ‘n’ button after the end of his trial, while the ‘y’ button is not recorded for it, so the next trial of the first subject starts but does not start for the second subject!  
Would you please explain how to wait for both key presses before moving forward?  
Thanks,  
Fazel

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [June 10, 2021, 2:06pm UTC](https://discourse.psychopy.org/t/the-two-participants-perform-an-experiment-at-the-same-time/22191/22 "2021-06-10T14:06:44Z")

</div>

In that case @Becca 's [earlier proposal](https://discourse.psychopy.org/t/the-two-participants-perform-an-experiment-at-the-same-time/22191/13) should work.

You need the trial to wait for both keys to be pressed before moving on but record the relevant key press and, for example, replace the stimulus with a blank or text.

---

<div class="post-metadata">

**Author:** ![fazel\_amirvahedi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/fazel_amirvahedi/32/10785_2.png) [@fazel\_amirvahedi](https://discourse.psychopy.org/u/fazel_amirvahedi)\
**Post date:** [June 10, 2021, 8:30pm UTC](https://discourse.psychopy.org/t/the-two-participants-perform-an-experiment-at-the-same-time/22191/23 "2021-06-10T20:30:41Z")

</div>

I mean something like this:

 ![Screenshot 2021-06-10 195027](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/1/3/13140c9c9ab892ab5b3dc32193afd0267cc9e26c.png)  
I created a variable called “flag\_B” in the feedback2 routine of the second subject and created a keyboard component(feed2\_resp) so that if the first subject presses the ‘y’ button when the feedback of the second subject is playing, it will be taken by the keyboard component and saved in the flag\_B.  
 ![keyboard](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/4/a/4ac064ba5cf0977e48c51e1c3fbea8ddd1699ad0.png)  
And I call the flag\_B variable at the beginning of the trial(fixpnt) so that if the first subject has already pressed the ‘y’ key, it will be considered using the “or” command in the code.  
 ![fixpnt](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/5/9/592a56f38b7086721ef97d8b03d0636b34575f1b.png)  
But in this case, I do not know why when I run the task\_B and press the ‘n’ button first, it completely leaves the task, while if I hit the ‘y’ button first, this does not happen! Also, this happens only in the first trial and in the next trials, if I press ‘n’ first, it will not go out of task!  
I appreciate any comments.  
Fazel

---

<div class="post-metadata">

**Author:** ![fazel\_amirvahedi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/fazel_amirvahedi/32/10785_2.png) [@fazel\_amirvahedi](https://discourse.psychopy.org/u/fazel_amirvahedi)\
**Post date:** [June 10, 2021, 8:35pm UTC](https://discourse.psychopy.org/t/the-two-participants-perform-an-experiment-at-the-same-time/22191/24 "2021-06-10T20:35:48Z")

</div>

> [@wakecarter](#):
>
> for example, replace the stimulus with a blank or text.

Hi [Wakecarter](https://discourse.psychopy.org/u/wakecarter),  
thanks for your help.  
Can you tell me what you mean by replacing the stimulus with a blank or text?  
Also I think that I have done the Becca’s earlier proposal [here](https://discourse.psychopy.org/t/the-two-participants-perform-an-experiment-at-the-same-time/22191/14) ?!  
Thanks,  
Fazel

[Previous page](https://discourse.psychopy.org/t/the-two-participants-perform-an-experiment-at-the-same-time/22191.md?page=1)
