I’m currently designing a task where I need psychopy to register when a key is released, rather than when it is pressed.
I’m not much of a coder, but from what I understand, since iohub has been integrated with Psychopy by default, this should be quite simple. That is, I should just be able to use keyboard.getReleases instead of keyboard.getKeys here …or at least that’s the impression I get from the documentation.
Upon doing this though, I’m getting the following error:
AttributeError: ‘Keyboard’ object has no attribute ‘getReleases’
Aside from this change, the code is just what has been compiled from something that was created in builder. ( I was initially trying to import io hub myself and use the launchHubServer functions etc, before I realised that when you compile something from builder now it already has all of this done for you… so why not go with that)
I’ll leave it there for now, perhaps there is simply some info on this that I’m failing to locate and someone can point me in the right direction? Any leads are highly appreciated. If someone wants to look at the code I’ll upload it upon a reply.
Thanks a lot,
For anyone interested, we got this working in the end. Much of this code is available elsewhere…
At the start of the experiment:
import psychopy.iohub as io
from psychopy.hardware import keyboard
from psychopy.iohub import *
from psychopy.iohub.constants import EventConstants,KeyboardConstants
from psychopy.iohub.client import launchHubServer,ioHubConnection
from psychopy.data import getDateStr
from psychopy.core import getTime
#Create an ioHubConnection instance, which starts the ioHubProcess, and informs it of the requested devices and their configurations.
# New connection fails when case there’s already an ioHubConnection, get active connection
io = ioHubConnection.getActiveConnection()
in the begin routine section of the response routine
#Need to reset these events in case the participant already pressed and released one of the keys
#remember the current time so that we can get RTs relative to the trial start
stime = getTime()
z_released = False
z_response_event = None
m_released = False
m_response_event = None
In the each frame section of the response routine
# Get first Z key release
# Get first M key release
a few other bits are necessary, and some of those bits may have been unnecessary, but that was the basics…