Do you want the routine to end when the space bar is released?
It would be quite easy to add a code component to do this. Off the top of my head something like:
Begin Routine
spacePressed=0
Each Frame
keys = event.getKeys()
if len(keys):
if "space" in keys and spacePressed = 0:
spacePressed = t
elif spacePressed > 0:
rt = round((t-spacePressed)*1000)
thisExp.addData('SpaceDur',rt)
continueRoutine=False
Make sure you add a code_JS component as per my crib sheet.
Best wishes,
Wakefield