Molto interesante Marco.
My purpose to start with was to distinguish when the user was hitting SPC, ESC or ENTER to end the loop.
The last prompt should have been: "Select next object or ENTER to end selection", if at that point SPC or ESC were hit the function will quit, if ENTER is pressed then the function will proceed with the selected objects list.
But that's my problem, I don't know how to differentiate which key has been pressed to end the loop.