Simultaneous button pressing
 
 
 
PST User Forum
Home       Members    Calendar    Who's On
Welcome Guest ( Login | Register )
        



Simultaneous button pressing Expand / Collapse
Author
Message
Posted 7/10/2007 11:48:34 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 7/2/2008 6:40:39 AM
Posts: 8, Visits: 119
I have designed an experiment were participants have to respond to stimuli using either the A or L key on the keyboard. Once participants have made their response they have to press the G and H keys to proceed to the next trial.

As they can press either the G or the H key first the next key they press has to be the one they didn't press first...ie if they press H first then the second press has to be G and vice versa.

I think that an IF statement would work best here but I am having slight issues trying to code this in, I would be grateful for any help offered.

Joel
Post #471
Posted 7/11/2007 3:39:40 PM
Forum MVP

Forum MVPForum MVPForum MVPForum MVPForum MVPForum MVPForum MVPForum MVP

Group: Administrators
Last Login: Yesterday @ 9:26:59 AM
Posts: 576, Visits: 1,254
If you are ready to move to E-Prime 2.0, this is a few lines of code seen below which will work begining with E-Prime 2.0.1.80 or later.

Do

  If Keyboard.GetKeyState("h") = ebStatePress And _
   Keyboard.GetKeyState("g") = ebStatePress Then
    Exit Do
  End If

  Sleep 10
  DoEvents

 Loop

If you are in need of a E-Prime 1.x solution, then this will be a little bit more difficult.  I can not think of a way to use GUI objects only because there is no way to ensure that a certain key is down when you get the next object's input.  So you have to use a ton of script to rip through the collection of responses and determine what their state is.  Then when they are all presses at the same time you terminate the object.

The attached shows how this is done in a way that can take more than two presses and feeds what keys to press from a List.  The script will only work with characters that are not special having the {key} already around them but could be modified to handle that.  It also does not care if the values are G or g so no case sensitive.

To use the attached one would need to...

1) Copy the ProcessResponses InLine after the object you wish to make this happen.

2) Edit the name of the object at the top of the InLine to match your object

3) Make the Keyboard accept Presses and Release in Exp Object / Devices

4) In your response collection object, set duration to zero, set the allowable to {ANY}{-ANY}, time limit infinite, end resp action = none, set the MaxCount to 1000 or higher.

5) Create an attribute called Keys and put the keys that need to be pressed together (“abc”, “gh”, etc)

-Brandon

 


  Post Attachments 
PressAllKeys.es (10 views, 12.77 KB)

Post #479
Posted 7/12/2007 7:52:47 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 7/2/2008 6:40:39 AM
Posts: 8, Visits: 119
Dear Brandon

Thank you very much, your code works a treat, after looking at what you have done I am in no doubt that if I had to do it myself I would not have been able to.

Sincerely,

Joel
Post #482
Posted 9/20/2007 9:46:16 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 7/2/2008 6:40:39 AM
Posts: 8, Visits: 119
Dear Brandon

Thank you for the help you have given me so far, it is appreciated. Could I trouble you slightly adjust a piece of code that you supplied me with.

Can it be adjusted so the participant holds down the two buttons, then whilst they are holding them the program waits a random period of time, then presents the stimuli. The participant then releases the buttons and makes a response dependent on the stimuli presented.

I can get the code to press, release, wait random time, present, respond but I am having trouble with press, wait random time, present, release, respond.

Sincerely

Joel
Post #638
Posted 9/20/2007 11:05:52 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 7/2/2008 6:40:39 AM
Posts: 8, Visits: 119
Just realized it is slightly more complicated, as there will be catch trials where no response is needed to be made so the program should proceed to the next trial after a certain time period but with the participant still holding down the two keys...


Post #639
Posted 6/17/2008 7:38:38 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 7/2/2008 6:40:39 AM
Posts: 8, Visits: 119
Would it be possible to adjust the code you gave me slightly, basiclly I just need the code to allow the participant to hold down either the '2' or '3' key whilst making their left/right repsonse and then proceed to the next trial when they repress the released '2' or '3' key again.

Ie a trial starts with the participant holding done the '2' key with their left hand and the '3' key with their right. The word left appears to the left of the screen and the participant lifts their left hand off the '2' key and presses the '1' key. This is whilst they keep the '3' key pressed down with their right hand, after they press the '1' key they return their hand to the '2' key and press and hold it down which should start the next trial (the opposite would be true if the word right appeared). At the moment participants have to left both of their hands off the '2' and '3' key and repress them to start the next trial.

Is this possible? I have attached the code with four examples, two left and two right.

Joel


  Post Attachments 
test code.es (0 views, 38.40 KB)
Post #1682
« Prev Topic | Next Topic »


Permissions Expand / Collapse