Registering key releases rather than key presses

Hi all,

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,
Simon

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.
try:
# io=launchHubServer()
io=ioHubConnection()
except:
# New connection fails when case there’s already an ioHubConnection, get active connection
io = ioHubConnection.getActiveConnection()

iokeyboard=io.devices.keyboard

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
io.clearEvents()
iokeyboard.clearEvents()

#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
z_key_releases=iokeyboard.getReleases(keys=[‘z’])
if z_key_releases:
# Get first Z key release
z_response_event=z_key_releases[0]
z_released=True

m_key_releases=iokeyboard.getReleases(keys=[‘m’])
if m_key_releases:
# Get first M key release
m_response_event=m_key_releases[0]
m_released=True

a few other bits are necessary, and some of those bits may have been unnecessary, but that was the basics…