Bypass a return from a text input styled dialog box

Is there any way to avoid having to press the return or enter key to accept the input text from a dialog such as this one? In other words, if the operator typed the number 5 in the dialog box, the dialog box would immediately act as if “OK” was triggered, and then allow the 5 to be passed to a variable and used later in the script?

set userInput to display dialog "Enter a number from 1-9" buttons {"Cancel", "OK"} default button 2 default answer "1"
set theNumber to text returned of userInput

Not with display dialog, but you can do this in AppleScript Studio

Thank you Stefan, that’s what I needed to see. Have a great day.

Thanks, I have just 73 min left. It’s 10:47 pm here :wink:
But I will keep me awake to watch the US election

You better start pounding the coffee, you are in for a long night :slight_smile:

I am aware of that :slight_smile: