Re: Key-release-event
| From: | Richard Lynch | Date: | Thu, 27 Jan 2005 22:22:00 +0000 |
| Subject: | Re: Key-release-event | ||
| References: | 1 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-5504@lists.php.net to get a copy of this message | ||
Emiel Mols wrote:
> I understand :), but I'm trying to build an application which controls
> some
> robotics. Since I want the robot to stop moving when I stop pressing a
> key,
> I need a key-release-event to do this. In the Control panel I can't turn
> this 'feature' of. Furthermore, the key-release-event occurs directly
> after
> the key-press-event, so it's quite useless.
In the key-released function, record the time and start a timer for X
seconds.
In your key-pressed function, check the time since the recorded. If it's
< X, they are still holding the key down, so kill the timer previously set
in key-released.
Eventually, a timer will survive because they stopped holding the key, and
you can use THAT to fire your robot stopping.
You'll probably want to bind the key pressed and whatnot into the timers,
but you get the idea.
--
Like Music?
http://l-i-e.com/artists.htm