OK, you want to follow roughly the guidance in this post But some tweaks.
Add a code component.
In the Begin Experiment tab:
import serial
port = serial.Serial('COM1')# where COM1 is the address of your port
In the Begin Routine tab
CountedKeys = 0
In the Each frame tab
if len(key_resp.keys) > CountedKeys:
CountedKeys += 1 # increase the keys that were counted
port.write([0x01]) # sent the trigger
Make sure you have a keyboard component that is called “key_resp” where Data > Store data is set to “All Keys”
Please do feed back if that works.
Hope this helps,
Becca