Re: Eu2.1: get_key(): how know when RELEASED
Irv, Hawke,
Thanks, but although I haven't yet tried it, I think I found a solution to
my problem, & it's real simple if it works: since my intention was to have
get_key() set a variable one way or another depending on whether a
particular key was pressed or not (including "not pressed" because it had
been *released*), (and I didn't really *ask* my question in that form, like
I should have!), it would seem that all I have to do is use the simple idea
of...INITIAL CONDITION to set my responding variable to what I want it to be
*if the key ISN'T pressed*, and then let it get changed by get_key if it IS
pressed. That should do it just fine. Sigh.
Dan
--------------------------------------------------------------------
On Sat, 26 Aug 2000, Dan wrote:
> Anyone know how I can tell when a key is RELEASED? As far as I can tell,
> get_key returns a bunch of -1's even when a key IS pressed, and tosses in
> the actual key pressed every once and a while; it does that fast enough &
> often enough to allow "if get_key() != -1" to pick up the sporadic
instance
> of not -1 when it occurs, but makes an "else =-1" not able to signify no
> key pressed, because of all the -1's spit out along even when an actual
key
> is pressed.
>
> Am I misunderstanding something here?
----------------------------------------------------------------------------
<and Irv wrote:>
>>Only in that the key _isn't_ pressed, even if you're sitting on it, if you
have keyboard >>repeat turned on. The repeat function "releases" and
"presses" the key
>>a few times a second as long as you hold the key down.
>>That's why you get the key val, followed by -1's, then the key, etc.
Yes, that did *finally* dawn on me after I saw how similar the quantity of
returned -1's were when key was held down!
>>I think (someone will correct me if I'm wrong) you'll have to go to a
lower
>>level (dos interrupts) to get a key-release code. Will that work without
>>turning off the auto-repeat ?
I considered that, with horror, but hopefully the "set initial condition"
solution will suffice; thanks!
>>Irv
----------------------------------------------------------------------------
---
<and Hawke wrote:>
>> from keyread.e in the archive:
>> -- Here's an extremely useful library routine for reading the keyboard.
>> -- It is used just like get_key(), except that it's called get_keys(),
>> -- it returns a sequence instead of an atom, and the values returned are
> >-- scan codes, instead of ASCII codes.
>> -- The advantage is that the routine will recognize multiple keypresses
> >-- at the same time, and return them in one sequence.
> >-- Also, there is no repeat delay, instead the code is returned
constantly
> >-- until the key is released.
> >-- Finally, the routine is also some 10-20 times faster than get_key()
> >-- Regards,
> >-- Michael Bolin
> >-- June 1997
> >hope this helps, Hawke'
Hawke, I'm going to remember this, 'cause it might come in handy another
time! Thanks.
Dan
|
Not Categorized, Please Help
|
|