Sending multiple triggers pressing the same key using serial port

Hi everybody,

I would like to know how to send to EGI Netstation a trigger anytime a key is pressed. Participants can press the key multiple times and I need to see a trigger on NetStation everytime it has been pressed. How can I do it?

For all the stimuli in the routine, I’m using the code provided here: Sending triggers via EGI NetStation — PsychoPy v2023.2.3.

In Begin Routine tab:

triggerSent = False

In Each Frame tab:

if check.keys and not triggerSent:
win.callOnFlip(eci_client.send_event, event_type = 'chec', label='chec') 
triggerSent = True

Thank you!

UPDATE:
I just used the lenght of the event ‘check.keys’ in order to send triggers at every press of the same key.

if check.keys and not triggerSent:
win.callOnFlip(eci_client.send_event, event_type = 'chec', label='chec') 
triggerSent = True

if len(check.keys)>1 and not trigger2Sent:
win.callOnFlip(eci_client.send_event, event_type = 'chec', label='chec') 
trigger2Sent = True

if len(check.keys)>2 and not trigger3Sent:
win.callOnFlip(eci_client.send_event, event_type = 'chec', label='chec') 
trigger3Sent = True
# etc. until the expected number of presses

If you have some more elegant way to do it, it would be appreciated :slightly_smiling_face: Thank you!