You could log the reaction time and then yield for an additional amount of time equal to 3 seconds minus the reaction time:
Code:
import viz
import viztask
viz.go()
def MyTask():
waitKey = viztask.waitKeyDown(' ')
waitTime = viztask.waitTime(3)
while True:
print 'start'
#Wait for next frame to be drawn to screen
d = yield viztask.waitDraw()
#Save start time
startTime = d.time
d = yield viztask.waitAny( [ waitKey, waitTime ] )
if d.condition is waitKey:
keyData = d.data
elapsed = keyData.time - startTime
print 'The spacebar was pressed after {:.2f} seconds'.format(elapsed)
yield viztask.waitTime(3-elapsed)
elif d.condition is waitTime:
print '3 seconds passed, the spacebar was not pressed'
viztask.schedule( MyTask() )