## Count Button Presses in Trial with Fixed Duration

 Author Message Pete Associate Member Group: Forum Members Posts: 2, Visits: 6 Hi everyone,I'm trying to create a trial lasting 3 min in which participants have to press the spacebar every time they come up with an idea. I would like to count how many times the participant presses the spacebar and if possible at what exact points in time during the 3 min interval the presses took place. I would really appreciate any help as I seem to be stuck. Dave Supreme Being Group: Administrators Posts: 9.8K, Visits: 46K +xPete - Monday, November 20, 2017Hi everyone,I'm trying to create a trial lasting 3 min in which participants have to press the spacebar every time they come up with an idea. I would like to count how many times the participant presses the spacebar and if possible at what exact points in time during the 3 min interval the presses took place. I would really appreciate any help as I seem to be stuck.You can achieve this using /isvalidresponse:/ trials = [1=ideatrial]/ stimulusframes = [1=ideatext]/ validresponse = (57)/ isvalidresponse = [if (trial.ideatrial.response == 57) {values.spacebarcount +=1; values.keypresstimes = concat(concat(values.keypresstimes, trial.ideatrial.latency), ";"); false}]/ timeout = 30000/ spacebarcount = 0/ keypresstimes = ""/ items = ("Press the spacebar whenever you have an idea.")/ columns = [date time subject group blocknum blockcode trialnum trialcode stimulusitem response latency     values.spacebarcount values.keypresstimes]/ separatefiles = trueYou'll find the total number of spacebar presses logged in values.spacebarcount; you'll find a list of the exact times when the presses occurred in values.keypresstimes (in milliseconds, measured from the start of the trial). Pete Associate Member Group: Forum Members Posts: 2, Visits: 6 Thank you very much! Works perfectly!