Trouble converting coder to builder using keyboard library

I managed to get it to work by using a code snippet in builder:

from psychopy import event

kb = keyboard.Keyboard()

continuing = True

while continuing:
    remainingKeys = kb.getKeys(waitRelease=True)
    if remainingKeys:
        for key in remainingKeys:
            if key.name=='space':
                continuing = False

I have the square as one routine, a blank text object as a routine, and the code snippet as a routine.

Now to convert this to JS…