Code for Resp triggers

Hello Psychopy Experts!
We are trying to set up a BrainVision EEG system. We used the Python example code, which is provided by the Brain Products, and wrote the code below to send stimulus triggers. It worked and we could see the triggers on the BrainVision Recorder software. The only thing about this code is that when we try to escape the experiment when it is not finished, the computer freezes and then crashes.





But, when we changed the code according to some of the example codes on this forum to send response triggers, it not only didn’t work, but also caused the stimulus triggers not to be sent to the recorder. You can see the code below:





I would be grateful if you could let us know what the problem is with our code and how we can fix it.
Thanks.