Help with modifying existing script to use keyboard input, rather than mouse


Help with modifying existing script to use keyboard input, rather than...

Author
Message
emotion39
emotion39
Associate Member
Associate Member (60 reputation)Associate Member (60 reputation)Associate Member (60 reputation)Associate Member (60 reputation)Associate Member (60 reputation)Associate Member (60 reputation)Associate Member (60 reputation)Associate Member (60 reputation)Associate Member (60 reputation)

Group: Awaiting Activation
Posts: 3, Visits: 12
Our lab is trying to modify a Cyberball script to use the keyboard, rather than mouse to throw to particular targets. 

We don't want the mouse cursor to show up because we are going to be recording videos of various Cyberball interactions (e.g., over inclusion, exclusion, inclusion, etc.), and we would like to have people watch videos of those interactions. Because we don't want to induce perspective taking, we are hoping to record the videos with no mouse cursor. We first tried / inputdevice = mousekey, but then realized that we couldn't select targets when we did that. Then, we tried modifiying / validresponse = (player1, player2) to / validresponse = ("a," "l") in order to select the targets by pressing A or L, but when we launch and press the keys, it just advances to the next screen. 

Right now, participants have to *click* on the blue smiley or green smiley for the ball to be thrown to them. 

Including some of the code and a picture of our paradigm.  

Here is our code.  
<block excludedbyC>
/ bgstim = (player1, player2, player1label, player2label, youlabel)
/ trials = [1 = yourturnexcludedbyC]
/ stop = [block.excludedbyC.trialcount >= 60]
</block>
<trial player1turnexcludedbyC3to1>
/ 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.player1inclusion.selectedvalue == 2) trial.player2turnexcludedbyC1to2]
/ branch = [if (counter.player1inclusion.selectedvalue == 3) trial.yourturnexcludedbyC1to3]
</trial>
<trial player1turnexcludedbyC2to1>
/ 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.player1inclusion.selectedvalue == 2) trial.player2turnexcludedbyC1to2]
/ branch = [if (counter.player1inclusion.selectedvalue == 3) trial.yourturnexcludedbyC1to3]
</trial>
<counter player1inclusion>
/ items = (2, 3)
/ select = noreplace
</counter>
<counter player2exclusion>
/ items = (1)
/ select = noreplace
</counter>
<trial yourturnexcludedbyC>
/ stimulusframes = [1=ball3, blank2, blank1, selectinstructions]
/ validresponse = (player1, player2)
/ branch = [if (trial.yourturnexcludedbyC.response == "player1") trial.player1turnexcludedbyC3to1]
/ branch = [if (trial.yourturnexcludedbyC.response == "player2") trial.player2turnexcludedbyC3to2]
</trial>
<trial player2turnexcludedbyC3to2>
/ 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)
/ timeout = 800
/ branch = [if (counter.player2exclusion.selectedvalue == 1) trial.player1turnexcludedbyC2to1]
/ branch = [if (counter.player2exclusion.selectedvalue == 3) trial.yourturnexcludedbyC2to3]
</trial>
<trial player2turnexcludedbyC1to2>
/ 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)
/ timeout = 800
/ branch = [if (counter.player2exclusion.selectedvalue == 1) trial.player1turnexcludedbyC2to1]
/ branch = [if (counter.player2exclusion.selectedvalue == 3) trial.yourturnexcludedbyC2to3]
</trial>
<trial yourturnexcludedbyC2to3>
/ 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, selectinstructions]
/ validresponse = (player1, player2)
/ branch = [if (trial.yourturnexcludedbyC2to3.response == "player1") trial.player1turnexcludedbyC3to1]
/ branch = [if (trial.yourturnexcludedbyC2to3.response == "player2") trial.player2turnexcludedbyC3to2]
</trial>
<trial yourturnexcludedbyC1to3>
/ 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, selectinstructions]
/ validresponse = (player1, player2)
/ branch = [if (trial.yourturnexcludedbyC1to3.response == "player1") trial.player1turnexcludedbyC3to1]
/ branch = [if (trial.yourturnexcludedbyC1to3.response == "player2") trial.player2turnexcludedbyC3to2]
</trial>


Also, Our default settings are as follows:
************************
***DEFAULTS*********
*************************
<defaults>
/ minimumversion = "3.0.1.1"
/ inputdevice = mouse
/ fontstyle = ("Verdana", 18pt, false, false, false, false, 5, 0)
</defaults>

And here is a picture:




Hoping for some help or a workaround to the screen recording issue! Thank you very much.


Dave
Dave
Supreme Being
Supreme Being (493K reputation)Supreme Being (493K reputation)Supreme Being (493K reputation)Supreme Being (493K reputation)Supreme Being (493K reputation)Supreme Being (493K reputation)Supreme Being (493K reputation)Supreme Being (493K reputation)Supreme Being (493K reputation)

Group: Administrators
Posts: 9.1K, Visits: 39K
emotion39 - Tuesday, June 26, 2018
Our lab is trying to modify a Cyberball script to use the keyboard, rather than mouse to throw to particular targets. 

We don't want the mouse cursor to show up because we are going to be recording videos of various Cyberball interactions (e.g., over inclusion, exclusion, inclusion, etc.), and we would like to have people watch videos of those interactions. Because we don't want to induce perspective taking, we are hoping to record the videos with no mouse cursor. We first tried / inputdevice = mousekey, but then realized that we couldn't select targets when we did that. Then, we tried modifiying / validresponse = (player1, player2) to / validresponse = ("a," "l") in order to select the targets by pressing A or L, but when we launch and press the keys, it just advances to the next screen. 

Right now, participants have to *click* on the blue smiley or green smiley for the ball to be thrown to them. 

Including some of the code and a picture of our paradigm.  

Here is our code.  
<block excludedbyC>
/ bgstim = (player1, player2, player1label, player2label, youlabel)
/ trials = [1 = yourturnexcludedbyC]
/ stop = [block.excludedbyC.trialcount >= 60]
</block>
<trial player1turnexcludedbyC3to1>
/ 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.player1inclusion.selectedvalue == 2) trial.player2turnexcludedbyC1to2]
/ branch = [if (counter.player1inclusion.selectedvalue == 3) trial.yourturnexcludedbyC1to3]
</trial>
<trial player1turnexcludedbyC2to1>
/ 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.player1inclusion.selectedvalue == 2) trial.player2turnexcludedbyC1to2]
/ branch = [if (counter.player1inclusion.selectedvalue == 3) trial.yourturnexcludedbyC1to3]
</trial>
<counter player1inclusion>
/ items = (2, 3)
/ select = noreplace
</counter>
<counter player2exclusion>
/ items = (1)
/ select = noreplace
</counter>
<trial yourturnexcludedbyC>
/ stimulusframes = [1=ball3, blank2, blank1, selectinstructions]
/ validresponse = (player1, player2)
/ branch = [if (trial.yourturnexcludedbyC.response == "player1") trial.player1turnexcludedbyC3to1]
/ branch = [if (trial.yourturnexcludedbyC.response == "player2") trial.player2turnexcludedbyC3to2]
</trial>
<trial player2turnexcludedbyC3to2>
/ 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)
/ timeout = 800
/ branch = [if (counter.player2exclusion.selectedvalue == 1) trial.player1turnexcludedbyC2to1]
/ branch = [if (counter.player2exclusion.selectedvalue == 3) trial.yourturnexcludedbyC2to3]
</trial>
<trial player2turnexcludedbyC1to2>
/ 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)
/ timeout = 800
/ branch = [if (counter.player2exclusion.selectedvalue == 1) trial.player1turnexcludedbyC2to1]
/ branch = [if (counter.player2exclusion.selectedvalue == 3) trial.yourturnexcludedbyC2to3]
</trial>
<trial yourturnexcludedbyC2to3>
/ 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, selectinstructions]
/ validresponse = (player1, player2)
/ branch = [if (trial.yourturnexcludedbyC2to3.response == "player1") trial.player1turnexcludedbyC3to1]
/ branch = [if (trial.yourturnexcludedbyC2to3.response == "player2") trial.player2turnexcludedbyC3to2]
</trial>
<trial yourturnexcludedbyC1to3>
/ 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, selectinstructions]
/ validresponse = (player1, player2)
/ branch = [if (trial.yourturnexcludedbyC1to3.response == "player1") trial.player1turnexcludedbyC3to1]
/ branch = [if (trial.yourturnexcludedbyC1to3.response == "player2") trial.player2turnexcludedbyC3to2]
</trial>


Also, Our default settings are as follows:
************************
***DEFAULTS*********
*************************
<defaults>
/ minimumversion = "3.0.1.1"
/ inputdevice = mouse
/ fontstyle = ("Verdana", 18pt, false, false, false, false, 5, 0)
</defaults>

And here is a picture:




Hoping for some help or a workaround to the screen recording issue! Thank you very much.


If you're going to switch things to keyboard input, you not only need to change /validresponse and set the proper /inputdevice, you also need to adjust the various /branch attributes in your script accordingly. So, taking

<trial yourturnexcludedbyC>
/ stimulusframes = [1=ball3, blank2, blank1, selectinstructions]
/ validresponse = (player1, player2)
/ branch = [if (trial.yourturnexcludedbyC.response == "player1") trial.player1turnexcludedbyC3to1]
/ branch = [if (trial.yourturnexcludedbyC.response == "player2") trial.player2turnexcludedbyC3to2]
</trial>

as example, you would switch that to keyboard input like so

<trial yourturnexcludedbyC>
/ inputdevice = keyboard
/ stimulusframes = [1=ball3, blank2, blank1, selectinstructions]
/ validresponse = ("a", "l")
/ branch = [if (trial.yourturnexcludedbyC.response == 30) trial.player1turnexcludedbyC3to1]
/ branch = [if (trial.yourturnexcludedbyC.response == 38) trial.player2turnexcludedbyC3to2]
</trial>

30 is the keyboard scan code associated with the "a"-key on an English-language QWERTY keyboard; 38 is the keyboard scan code associated with the "l"-key.

(See the "Keyboard Scan Codes" topic in the documentation as well as Tools -> Keyboard Scancodes...)


emotion39
emotion39
Associate Member
Associate Member (60 reputation)Associate Member (60 reputation)Associate Member (60 reputation)Associate Member (60 reputation)Associate Member (60 reputation)Associate Member (60 reputation)Associate Member (60 reputation)Associate Member (60 reputation)Associate Member (60 reputation)

Group: Awaiting Activation
Posts: 3, Visits: 12

Take you for the response, Dave!

We will try this out!!
emotion39
emotion39
Associate Member
Associate Member (60 reputation)Associate Member (60 reputation)Associate Member (60 reputation)Associate Member (60 reputation)Associate Member (60 reputation)Associate Member (60 reputation)Associate Member (60 reputation)Associate Member (60 reputation)Associate Member (60 reputation)

Group: Awaiting Activation
Posts: 3, Visits: 12
Reporting back that it worked! Thank you!!
Dave
Dave
Supreme Being
Supreme Being (493K reputation)Supreme Being (493K reputation)Supreme Being (493K reputation)Supreme Being (493K reputation)Supreme Being (493K reputation)Supreme Being (493K reputation)Supreme Being (493K reputation)Supreme Being (493K reputation)Supreme Being (493K reputation)

Group: Administrators
Posts: 9.1K, Visits: 39K
emotion39 - Tuesday, June 26, 2018
Reporting back that it worked! Thank you!!

Wonderful -- thanks for letting me know!

GO


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....






Millisecond Forums


Search