{handle:'number', on:'keypressed', key:['1','2','3','4','5','6','7','8','9']}
{ conditions: [{type:'inputEquals',value:'number'}], actions:[ {type:'setTrialAttr', setter: function(trialData,inputData){ trialData.score = inputData.event.key; }} ]}
I think this has to do with inserting
{handle:'number', on:'keypressed', key:['1','2','3','4','5','6','7','8','9']},
in actions
, and not in input
:
API.addTrialSets('Trial',
{
layout: [
{media: {word:'This is a fear conditioning task'},
location:{top:94},css: {color:'#0000ff', 'font-size':'1em'}}
],
input: [
{handle:'number', on:'keypressed', key:['1','2','3','4','5','6','7','8','9']}
],
interactions: [
{
conditions:[{type:'inputEquals',value:'showMyStim'}],
actions: [
{type:'resetTimer'},
{type:'hideStim',handle: 'fixation'},
{type:'showStim', handle: 'cue'},
{type:'showStim', handle: 'layoutanswers'},
{type:'setInput',input:{handle:'time',on:'timeout',duration:4000}},
{type:'setTrialAttr',setter:{rated:'no'}},
]
},
{
conditions: [
{type:'inputEquals',value:'number'}
],
actions: [
{type:'custom',fn:function(){console.log('no')}},
{type:'setTrialAttr', setter: function(trialData,inputData){
trialData.score = inputData.event.key;
}},
{type:'log'},
{type:'setTrialAttr',setter:{rated:'yes'}},
{type:'removeInput',handle:['number']},
{type:'hideStim',handle:'layoutanswers'}
]
}
{ data:[...]}