I don't think right-click (since you can only get that using grread, which then means entsel doesn't happen). Unfortunately only space/enter would stop entsel without erroring out like esc does. So you could go and use initget with a keyword and 128 as the code. Then also add that keyword as a default (i.e. in between <> in the message). If you do so, then entsel would return the keyword string when the user pressed Enter/Space.
As a sample:(defun EntSelChk (msg init chk / en err)
(while (and (progn
(if init
(apply 'initget init)
)
(setq en (entsel msg))
)
(listp en)
(setq err (apply chk (list en)))
)
(princ err)
)
en
)
(defun c:Test (/ en check)
(defun check (en / )
(if (not (wcmatch (cdr (assoc 0 (entget (car en)))) "LINE,LWPOLYLINE"))
"\nThat's not a line / polyline, please try again."
)
)
(while (and (setq en (EntSelChk "\nSelect line / polyline <Exit>: " '("Exit" 128) 'check))
(not (eq en "Exit")))
(princ "\nYou've picked an acceptable entity")
)
(princ "\nYou've selected to exit.")
(princ)
)
Edit: scratch that, just realised it still doesn't do as intended. Will look a bit further and come back.