Capture user input while program is running

Is there a way to capture user input while a program is running? I’d like to add a popup step (blocking or non-blocking) that sends the text input to the backend (urscript).
Something like: input = popoup("enter command")
Is this feasible?

Thanks in advance