read-key timeout?
-
- Posts: 2038
- Joined: Tue Nov 29, 2005 8:28 pm
- Location: latiitude 50N longitude 3W
- Contact:
read-key timeout?
Is there a way of calling read-key so that if nothing is read for a certain time - eg a half-second - it completes?
The following program would work for 'read-line' but not for 'read-key':
The loop exits when something is entered or 5 seconds have passed.
Of course this would work only on MacOS X and UNIX. There may be a better solution working on individual keystrokes via importing some functions from the curses library?
Lutz
ps: I am not available on this board all Thursday (travelling).
pps: please post only news and documentation stuff in the news section.
Code: Select all
#!/usr/bin/newlisp
(print "Enter something:")
(set 'cnt 0)
(while (and (= (peek 0) 0) (< cnt 50)) (sleep 100) (inc 'cnt))
(if (< cnt 50)
(println "User entered: " (read-line))
(println "nothing was entered"))
(exit)
Of course this would work only on MacOS X and UNIX. There may be a better solution working on individual keystrokes via importing some functions from the curses library?
Lutz
ps: I am not available on this board all Thursday (travelling).
pps: please post only news and documentation stuff in the news section.
-
- Posts: 2038
- Joined: Tue Nov 29, 2005 8:28 pm
- Location: latiitude 50N longitude 3W
- Contact:
Pity - I'm looking for a way to see if a key is being pressed, but if it isn't, continuing on.Lutz wrote:The following program would work for 'read-line' but not for 'read-key':
OK - trouble is, I keep seeing "newlisp talk in general" and posting there... :-)Lutz wrote: pps: please post only news and documentation stuff in the news section.