Keyboard input/Keypress check: Difference between revisions

Add solution in Common Lisp
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
(Add solution in Common Lisp)
Line 544:
}
}</lang>
 
=={{header|Common Lisp}}==
==={{header|ncurses}}===
To interface the ncurses C library from Lisp, the ''croatoan'' library is used.
<lang lisp>(defun keypress-check ()
(with-screen (scr :input-echoing nil :input-blocking nil :input-buffering nil :enable-function-keys t)
(loop
;; Determine if a key has been pressed ...
(if (key-pressed-p scr)
;; ... and store this in a variable.
(let ((ch (get-char scr)))
;; exit the loop by pressing q.
(if (eql (code-char ch) #\q)
(return)
(princ (code-char ch) scr)))
(progn
;; If no key has been pressed, the program should continue without waiting.
(princ #\. scr)
(refresh scr)
;; we wait anyway to spare the CPU.
(sleep 0.15))))))</lang>
 
=={{header|C sharp|C#}}==
69

edits