Defining a key that ends routine in JS

It is set to store all keys.

I’ll try to explain a bit further. In my experiment, the participants see pictures on the screen and are required to press ‘right’ or ‘left’ in response to. Additionally, they can ask for a text which appears next to the picture by pressing ‘space’ (see the code I posted before)… but they still have to press ‘right’ or ‘left’ to continue the routine.
In the builder I used two blocks since I couldn’t get the Python code to allow only the ‘space’ key to make the text appear and the ‘right’ and ‘left’ keys to continue to the next picture. But JS does it in one block. So now, instead of having two blocks, I have only one block (with the options of pressing ‘right’, ‘left’ or ‘space’).
So in the builder I had a key and rt stored for each block individually. But now, I am lacking a code that makes sure that if ‘space’ is pressed, then the second response is also being saved (key + rt). And that the second response can only be ‘right’ or ‘left’.

Thanks for the help!