while-no-input

while-no-input is a Lisp macro in `subr.el'.

(while-no-input &rest BODY)

Execute BODY only as long as there's no pending input.
If input arrives, that ends the execution of BODY,
and `while-no-input' returns t. Quitting makes it return nil.
If BODY finishes, `while-no-input' returns whatever value BODY produced.