OS (e.g. Win10): Win 10
PsychoPy version (e.g. 1.84.x): 2013.1.2
Standard Standalone? (y/n) If not then what?:y
What are you trying to achieve?:
I want to have sequence of events where a fixation cross appears for at least 1.5s and the participant has to pressed down the space key for starting the first trial and make the cross disappears (this part works). Then I want the partcipant to release the space key, do some movements and then come back on the space key (this works as well). Then the fixation cross appears again but it can only disappear if I realease the space key (which I don’t want). I would like to detect basically that the key is still pressed down and if it is for 1.5s then the fixation can disappear and we can move to the next trial (in the current version when the fixation cross appears, I need to realease and pressed it back again)
I have attached a basic example about what I have right now.
dsp_test.psyexp (13.9 KB)
I am not sure if my original request was clear enough.
To make it simpler, which function could I use to permanently check the keyboard state? Something that could let me know whether no key is pressed down or instead whether a key is pressed down and returning the key name. Most importantly I need to track this in a permanent way (that is if a new routine starts and a key is already down then there is no need to release the key like I have to do right now to end the routine).
I’m having issues with this too. The new keyboard component can detect keyboard releases as well as presses, but it seems like a release can only be detected if the press happens in the same routine.
I find that monitoring a mouse button state is easier.
if mouse.getPressed() == 1: should be true whenever the left mouse button is down.
I found a “low tech” way of implementing it (see attachment) but that is not great in the sense it won’t detect unexpected releases of the space bar. Indeed, I saw that it may be feasible to do so easily with the mouse. At the end, I am planning to use of a homemade external device communicating through an usb ftdi chip (I guess with the serial port), so maybe I should not spend too much time on this given it will be easier to use different libraries to record state changes. I also tried using the keyboard library from python that allows real time detection of the keyboard state, but for some reason that I am not sure the psychopy stop responding when trying to use this library (the window opens but then the stimuli never appears). Overall, my question is: would it be easier to record state changes in a permanent way with an usb ftdi chip than with the keyboard?
dsp_test.psyexp (20.6 KB)