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

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

Re: Inhibit more keyboard event during execution of function


From: Kevin Rodgers
Subject: Re: Inhibit more keyboard event during execution of function
Date: Mon, 28 Dec 2009 23:51:40 -0700
User-agent: Thunderbird 2.0.0.23 (Macintosh/20090812)

Mathias Dahl wrote:
I have made a small game for my kid that lets him press a key and that
will play a sound and display an image. It is implemented as a major
mode with a keymap where each key is defined using `define-key' and
bound to a special play command with a string of what to play (say,
"cow"). Now, it works for me, but when I tested this on my son today he
kept the key pressed way longer than I do, with the effect that the key
repeats, playing the sound many times. Quite annoying. Is there a way to
get around this? I have been thinking of having some timing built in so
that I will not play again unless a certain time has passed.

Also, even though I tell Emacs to draw the image first (using
`insert-image-file'), it is not displayed until the sound has stopped
playing (I use `play-sound-file'). Any way around this?

I don't know if this will work, but you could try let-binding
unread-command-events to nil while the sound is being played.
The idea is that any input events would be added to the queue,
but when the sound is done the queued events would be discarded
and the command loop wouldn't see them.

--
Kevin Rodgers
Denver, Colorado, USA





reply via email to

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