help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Capture ALL keystrokes


From: harven
Subject: Re: Capture ALL keystrokes
Date: Fri, 30 May 2008 02:57:48 -0700 (PDT)
User-agent: G2/1.0

On May 29, 12:36 pm, "Ben Forbes" <address@hidden> wrote:
> When some keystroke A is entered, I set a flag, and I want this flag
> to be unset if any keystroke is entered except some keystroke B. So
> basically, I only want keystroke B to have any effect if it is
> preceded by keystroke A. How can I do this?

Be more specific about what you are trying to achieve.
Bound the following command to key A. Pressing the A key
inserts the letter A. It then executes the command newline
repeatedly if B is pressed any amount of time.

(defun my-command ()
"After key A, key B executes the command newline repeatedly"
  (interactive)
  (insert "A")
  (while (equal (setq key (read-event)) ?B)
      (next-line))
  (push key unread-command-events))

(global-set-key "A" 'my-command)


reply via email to

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