OS (e.g. Win10): Win 10
PsychoPy version (e.g. 1.84.x): version 1.84.2
Standard Standalone? (y/n) If not then what?: y
What are you trying to achieve?:
I am showing flickering lines for a long time (12 seconds). Observers need to indicate the number of those lines by pressing number keys on keyboard. I expect observers to respond as many as times as they want to during those 12 seconds. I also have a parallel port: I sent triggers at the start of the experiment, stimulus onset, stimulus offset, and each key press.
What did you try to make it work?:
Following this post, I managed to send the triggers when observers pressed a key.
What specifically went wrong when you tried that?:
However, I cannot send the triggers as many times as the observer presses the same key. One trigger (that corresponds to one response key) can only be sent once. How can I send as many triggers as the same key is pressed?
Here is code snippet where I send the triggers for response keys:
mark2Sent = False
mark2Terminated = True
mark3Sent = False
mark3Terminated = True
if resp.status == STARTED: theseKeys = event.getKeys( keyList=['num_0', 'num_1', 'num_2', 'num_3', 'num_4', 'num_5', 'num_6', 'num_7', 'num_8', 'num_9']) # check for quit: if "escape" in theseKeys: endExpNow = True if len(theseKeys) > 0: # at least one key was pressed resp.keys.extend(theseKeys) # storing all keys resp.rt.append(resp.clock.getTime()) if (resp.status == STARTED) and not mark2Sent: if len(resp.keys) > 0: if 'num_0' in resp.keys: p_port.setData(int(10)) mark_start_time = t mark2Sent = True mark2Terminated = False print (int(10)) if mark2Sent and not mark2Terminated: if t - mark_start_time >= 0.020: p_port.setData(int(0)) mark2Terminated = True print (int(0)) if (resp.status == STARTED) and not mark3Sent: if len(resp.keys) > 0: if 'num_1' in resp.keys: p_port.setData(int(11)) mark_start_time = t mark3Sent = True mark3Terminated = False print (int(11)) if mark3Sent and not mark3Terminated: if t - mark_start_time >= 0.020: p_port.setData(int(0)) mark3Terminated = True print (int(0))
Any help would be greatly appreciated!