Millisecond Forums

Using keyboard instead of a mouse

https://forums.millisecond.com/Topic11363.aspx

By gsu - 9/30/2013

Hi,


We are using Inquisit for Cyberball in our lab and until now, participants selected which player they wanted to throw the ball to using the mouse. Now, we want them to use the keyboard. How can I assign keys to each player? Also, how can I make sure that those keys are the valid responses in each trial?


Here's an example of a trial where we defined the input device as the mouse:


<trial instructions12>


/ stimulusframes = [1=cyberball, turninstructions12, start]


/ validresponse = (start)


/ inputdevice = mouse


/ responsemessage = (start, blankscreen, 0)


/ recorddata = false


</trial>


Here's another example:


<trial yourturnexcludedbyA>


/ stimulusframes = [1=ball3, blank2, blank1]


/ validresponse = (player1, player2)


/ inputdevice = mouse


/ branch = [if (trial.yourturnexcludedbyA.response == "player1") trial.player1turnexcludedbyA3to1]


/ branch = [if (trial.yourturnexcludedbyA.response == "player2") trial.player2turnexcludedbyA3to2]


</trial>



Thank you in advance,

Gizem
By Dave - 9/30/2013


<trial yourturnexcludedbyA>


/ stimulusframes = [1=ball3, blank2, blank1]


/ validresponse = (player1, player2)


/ inputdevice = mouse


/ branch = [if (trial.yourturnexcludedbyA.response == "player1") trial.player1turnexcludedbyA3to1]


/ branch = [if (trial.yourturnexcludedbyA.response == "player2") trial.player2turnexcludedbyA3to2]


</trial>


You need to set inputdevide to keyboard, enter the keys scancodes in validresponse and adjust the branches accordingly. More importantly, though, you'll to work through the original (mouse input) script until you sufficiently understand how it works before making any of these modifications. Otherwise you are going to break the code.



By gsu - 10/3/2013

Hi Dave,


Thanks for your reply. I followed everything you said and now what happens is that when I press on the keys (either e or i - doesn't matter), it automatically goes to the next page without letting me play the game. What do you think the problem might be?


Thanks!

By Dave - 10/3/2013

I cannot tell you without you providing the relevant code. If I were to hazard a guess, you have probably misspecified the /branch attributes. You *must* use keyboard scancodes as already detailed in my previous reply.

By gsu - 10/3/2013

Hi Dave,


Here's the relevant code for one of the conditions. I don't think I'll be able to solve this without your help. Thanks in advance!


 


<block excludedbyA>


 


/ bgstim = (player1, player2, player1label, player2label,
youlabel)


 


/ trials = [1 = yourturnexcludedbyA]


 


/ stop = [block.excludedbyA.trialcount >= 60]


 


</block>


 


 


 


 


** trials, excluded by A **


 


 


 


<trial player1turnexcludedbyA3to1>


 


/ pretrialpause = replace(100-2000)


 


/ stimulustimes = [1=ball3, blank2, blank1; 100=blank3,
ball1to3e; 200=blank1to3e; 220=ball1to3d; 320=blank1to3d; 340=ball1to3c;
440=blank1to3c; 460=ball1to3b; 560=blank1to3b; 580=ball1to3a; 680=blank1to3a;
700=ball1]


 


/ validresponse = (noresponse)


 


/ timeout = 800


 


/ branch = [if (counter.player1exclusion.selectedvalue == 2)
trial.player2turnexcludedbyA1to2]


 


/ branch = [if (counter.player1exclusion.selectedvalue == 3)
trial.yourturnexcludedbyA1to3]


 


</trial>


 


 


 


<trial player1turnexcludedbyA2to1>


 


/ pretrialpause = replace(100-2000)


 


/ stimulustimes = [1=ball2, blank3, blank1; 100=blank2,
ball1to2e; 200=blank1to2e; 220=ball1to2d; 320=blank1to2d; 340=ball1to2c;
440=blank1to2c; 460=ball1to2b; 560=blank1to2b; 580=ball1to2a; 680=blank1to2a;
700=ball1]


 


/ validresponse = (noresponse)


 


/ timeout = 800


 


/ branch = [if (counter.player1exclusion.selectedvalue == 2)
trial.player2turnexcludedbyA1to2]


 


/ branch = [if (counter.player1exclusion.selectedvalue == 3)
trial.yourturnexcludedbyA1to3]


 


</trial>


 


 


 


<counter player1exclusion>


 


/ items = (2)


 


/ select = noreplace


 


</counter>


 


 


 


<counter player2inclusion>


 


/ items = (1, 3)


 


/ select = noreplace


 


</counter>


 


 


 


<trial yourturnexcludedbyA>


 


/ stimulusframes = [1=ball3, blank2, blank1]


 


/ validresponse = (player1, player2)


 


/ inputdevice = mouse


 


/ branch = [if (trial.yourturnexcludedbyA.response ==
"player1") trial.player1turnexcludedbyA3to1]


 


/ branch = [if (trial.yourturnexcludedbyA.response ==
"player2") trial.player2turnexcludedbyA3to2]


 


</trial>


 


 


 


<trial player2turnexcludedbyA3to2>


 


/ pretrialpause = replace(100-2000)


 


/ stimulustimes = [1=ball3, blank2, blank1; 100=blank3,
ball3to2a; 200=blank3to2a; 220=ball3to2b; 320=blank3to2b; 340=ball3to2c;
440=blank3to2c; 460=ball3to2d; 560=blank3to2d; 580=ball3to2e; 680=blank3to2e;
700=ball2]


 


/ validresponse = (noresponse)


 


/ inputdevice = mouse


 


/ timeout = 800


 


/ branch = [if (counter.player2inclusion.selectedvalue == 1)
trial.player1turnexcludedbyA2to1]


 


/ branch = [if (counter.player2inclusion.selectedvalue == 3)
trial.yourturnexcludedbyA2to3]


 


</trial>


 


 


 


<trial player2turnexcludedbyA1to2>


 


/ pretrialpause = replace(100-2000)


 


/ stimulustimes = [1=ball1, blank2, blank3; 100=blank1,
ball1to2a; 200=blank1to2a; 220=ball1to2b; 320=blank1to2b; 340=ball1to2c;
440=blank1to2c; 460=ball1to2d; 560=blank1to2d; 580=ball1to2e; 680=blank1to2e;
700=ball2]


 


/ validresponse = (noresponse)


 


/ inputdevice = mouse


 


/ timeout = 800


 


/ branch = [if (counter.player2inclusion.selectedvalue == 1)
trial.player1turnexcludedbyA2to1]


 


/ branch = [if (counter.player2inclusion.selectedvalue == 3)
trial.yourturnexcludedbyA2to3]


 


</trial>


 


 


 


<trial yourturnexcludedbyA2to3>


 


/ pretrialpause = replace(100-2000)


 


/ stimulustimes = [1=ball2, blank3, blank1; 100=blank2,
ball3to2e; 200=blank3to2e; 220=ball3to2d; 320=blank3to2d; 340=ball3to2c;
440=blank3to2c; 460=ball3to2b; 560=blank3to2b; 580=ball3to2a; 680=blank3to2a;
700=ball3]


 


/ validresponse = (player1, player2)


 


/ inputdevice = mouse


 


/ branch = [if (trial.yourturnexcludedbyA2to3.response ==
"player1") trial.player1turnexcludedbyA3to1]


 


/ branch = [if (trial.yourturnexcludedbyA2to3.response ==
"player2") trial.player2turnexcludedbyA3to2]


 


</trial>


 


 


 


<trial yourturnexcludedbyA1to3>


 


/ pretrialpause = replace(100-2000)


 


/ stimulustimes = [1=ball1, blank3, blank2; 100=blank1,
ball1to3a; 200=blank1to3a; 220=ball1to3b; 320=blank1to3b; 340=ball1to3c;
440=blank1to3c; 460=ball1to3d; 560=blank1to3d; 580=ball1to3e; 680=blank1to3e;
700=ball3]


 


/ validresponse = (player1, player2)


 


/ inputdevice = mouse


 


/ branch = [if (trial.yourturnexcludedbyA1to3.response ==
"player1") trial.player1turnexcludedbyA3to1]


 


/ branch = [if (trial.yourturnexcludedbyA1to3.response ==
"player2") trial.player2turnexcludedbyA3to2]


 














































































































































































</trial>


By Dave - 10/3/2013

Please review my 1st reply where you will find all of this already covered. You need to do this


<trial yourturnexcludedbyA>
/ stimulusframes = [1=ball3, blank2, blank1]
/ validresponse = (*enter scancode for player 1 key*, *enter scancode for player 2 key*)
/ inputdevice = keyboard
/ branch = [if (trial.yourturnexcludedbyA.response == *enter scancode for player 1 key*) trial.player1turnexcludedbyA3to1]
/ branch = [if (trial.yourturnexcludedbyA.response == *enter scancode for player 1 key*) trial.player2turnexcludedbyA3to2]

</trial>


throughout. For help with scancodes please review the respective documentation topic and see Tools -> Keyboard Scan Codes...