The object is to be able to interrupt a loop with a key stroke. currently all input functions are blocking and wait forever for input. Sometimes when no input is forth coming we need to be able to move on.
(net-peek and (net-connect with it's timeout are good examples of non-blocking input.
In windows we have the following workaround but nothing I can figure out for the other os's
Code: Select all
(if (not _kbhit) (import "msvcrt.DLL" "_kbhit" ))
(if (not _getch) (import "msvcrt.DLL" "_getch" ))
(define (key-pressed)
(if (= 0 (_kbhit)) nil
(begin
(setq keyval (_getch))
(if (or (= keyval 0)(= keyval 224)) (CONSOLE:_getch))
(setq keypress (char keyval)))))