[solved] Key realease
Hi
Does anyone know the best way to record a key release (rather than Press) in Opensesame? The participant will hold the response key (SPACEBAR) from the start of the trial until a certain event does or doesn't occur. I will need RTs recorded from the onset of an object (a new event) that will signify key release (or not) to the actual key release and also, from key release to a second mouse click (well, actually a touch screen input). Any help much appreciated
Comments
Hi JasT.
I had the same need in the past, so I can show you my solution (which requires a piece of python code).
I used pyglet KeyStateHandler function inside psycho backend, so I don't know if you can use the same function inside another backend. This is a simple code that you can adapt to your needs.
I don't know if there is a simpler method. Hope this helps.
Andrea
Thanks that's helpful - it makes sense to use a while loop to identify whether a key is no longer being pressed
">
Btw, in case you're not using the psycho back-end, here's a small code snippet that illustrates how you can accomplish approximately the same thing with the PyGame-based back-ends (legacy, expyriment, and opengl):
For more information, please see the PyGame documentation, and don't hesitate to post further questions!
Cheers,
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi,
I think this is a fantastic discussion; I have the same need for my study. I'm using sebastiaan's suggestion (for use with PyGame). However it doesn't seem to be recording the reaction time ("rt" variable). Or in fact, recording anything after the stimulus is presented. How do I get OpenSesame to record this part in logger?
And...I'm a little uncertain how this works in the experiment workflow. Do I place this Python script after the keyboard_response item, before it, or does it entirely replace the keyboard_response item?
Thanks,
Adam
Never mind! Some more googling found me this comment, also by Sebastiaan.
Basically, the python script needs to define the variable as well via
exp.set()so there should also be a line like this:exp.set('keyreleaseRT', rt)All good now! Although I have no idea what the last
printline is for, it doesn't seem to do anything.HI Adam,
The timing for each keypress should appear there, since this is were
prints usually print to.Anyway, good to hear that it works now for you.
Best,
Eduard
What does "there" mean? Is the screen supposed to display the
printline after I release the key? I'm not sure how that works since there isn't atext_renderitem around that part of the loop.Thanks,
Adam
Sorry! I think I rewrote my response and deleted something by accident. What "there" refers to is the
debug window. If you print something, it does't appear on the screen, but thedebug window.Sorry for the confusion.
Eduard
Thank you, Eduard!
Hi,
Sorry for resurrecting an old thread, but I was wondering if anyone had any information on how reliable the RT is using the method Andrea (Embodiment) proposed above. Would it be anywhere near millisecond accurate (ignoring issues tied to the particular keyboard itself)? Is it tied to screen refresh (the win.flip seems to suggest that, but I'm not sure)?
Thanks,
Mark