Key release as a reponse and record key duration

Dear all

Win10
**PsychoPy 3.1.0

I want to create an experiment, participants are required to press ‘v’ and ‘b’ keys, then press one of them when see the stimuli, and I want to record the key press duration.

I download the demo which was released in 2013 by Sol

Begin Experiment
try:
from psychopy.iohub import EventConstants,KeyboardConstants,ioHubConnection,load,Loader
from psychopy.data import getDateStr

# Load the iohub device config, file converting it to a python dict.
io_config=load(file('iohub_config.yaml','r'), Loader=Loader)

# Add / Update the session code to be unique. Here we use the psychopy getDateStr() function for session code generation
session_info=io_config.get('data_store').get('session_info')
session_info.update(code="S_%s"%(getDateStr()))

# Create an ioHubConnection instance, which starts the ioHubProcess, and informs it of the requested devices and their configurations.
io=ioHubConnection(io_config)
iokeyboard=io.devices.keyboard
iomouse=io.devices.mouse

class=“attachment” href=“//cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/flex020/uploads/psychopy/original/2X/c/cc25dcd6566b8f81e43264b9a1496caee4c81879.psyexp”>ImitInhib_v0.psyexp (41.8 KB)

The problem is " FixtionClock= core.Clock()" is invalid syntax

It can’t run, I think it’s due to some grammer changes, but I can’t find it, could you please help me?

We can’t really see the match between the (partial) error message you provide and the code. But perhaps you should instead just try the new keyboard handling that became available in version 3.1 and which should be easier to use:

http://www.psychopy.org/api/hardware/keyboard.html