Keyboard key very slow in interaction with USB TTL event marking module in builder

OS: Win10
PsychoPy version: 2024.2.4
Standard Standalone Installation? y
Do you want it to also run online? n
What are you trying to achieve? I am using a USB TTL event marking module from the black box toolkit to send and receive TTLs to my laptop.
What did you try to make it work?:
I used this code to send TTL through serial port and read upcoming TTLs.
import serial
ser = serial.Serial(‘COM3’, 115200,timeout=1)
ser.write(b’RR’)
ser.write(b’01’)
ser.write(b’00’)
line = ser.readline()
ser.close()

i am running this code in a super simple experiment in which I send/receive TTL and show text messages and press keyboard key.

What specifically went wrong when you tried that?
Problem 1: I am able to send and receive TTLs. however, in my routine, I added a keyboard key to continue to the next routine. It is super slow to move to the next routine only when I add the above code to interact with the USB TTL event marking module. Why is this the case?
Warning 1: When using ser.write(b’RR’)/ser.write(b’01’)/ser.write(b’00’), I see /* Syntax Error: Fix Python code */. It however still runs. Other combinations did not work. ser.write(‘00’), ser.write(“00”).