emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to know if a key is pressed without getting it?


From: Vinicius Jose Latorre
Subject: Re: How to know if a key is pressed without getting it?
Date: Sun, 26 Sep 2010 20:21:46 -0300
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.13) Gecko/20100914 SeaMonkey/2.0.8


Does anyone know how to know if a key is pressed without getting it in
Emacs (like kbhit like function)?
input-pending-p is a built-in function in `C source code'.

(input-pending-p)

Return t if command input is currently available with no wait.
Actually, the value is nil only if we can be sure that no input is available;
if there is a doubt, the value is t.

Well, Óscar Fuentes also sent me an email about input-pending-p.

I defined the following function using input-pending-p:

(defun test-input ()
  (read-char "char: ")
  (while (input-pending-p)
    (insert (format "{%S}" unread-command-events)))
  (message "{%S} END" last-input-char))

Execute the function above via: M-: (test-input) RET

Then hold space key.

The only message returned is "{32} END" followed by all spaces that I pressed (except the first one).

So, input-pending-p does not work as kbhit function.

I'm thinking that this function is not implemented in Emacs.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]