Multiple keyboard number presses

Apologies if my question is very similar to one previously asked, I tried quite a lot to implement what suggested in the following posts but unfortunately none worked in my case (I already tried with Display keyboard number presses and Writen response).

I would like to show an image onscreen up to when the participant presses the spacebar (rts should be recorded and saved in this moment), then the image should disappear and allow the participant to enter any number from 0-99 (that ideally should be displayed onscreen and saved in the csv file) and finally press return to move to the next trial.

This is how the builder and other components look like:

In code_stim/Begin routine I am coding the image I want to show, flip it and then using stop_rt = psychopy.event.waitKeys(keyList=[‘space’]) to ideally record the rts.
Up to here it works, in the sense that the image is shown onscreen until the participant presses the spacebar, but I don’t know how to save this rt in the cvs file.
Then I have added a keyboard component (screenshow above) and a code component (screenshow below) called code_resp trying to follow what suggested in the previous posts.

first, if I run it as it is I get the following error:
line 309, in key_num = int(key_str) ValueError: invalid literal for int() with base 10: ‘’
if I comment that line, the program is moving to the next trial already after I have entered the first digit (and not waiting for the second digit and then return) and, of course, it is saving only the first digit I have pressed.

My questions are:

  1. how do I save a column with the rts recorded when the subject pressed the spacebar in the cvs file
  2. how do I make the program display what the participant is typing and wait until the participant has entered the multidigit number and then return before moving to the next trial
  3. how do I save the multidigit number typed

Note: there is no need for me to use the keyboard component if all this can be implemented at the end of the code_stim section (I have tried that too but I did not succeed in making it work).

Thanks a lot for any advice in advance