How do I prevent a Key being pressed down all the time?

William de Smet williamdesmet at gmail.com
Sat Sep 27 15:11:14 EDT 2008


Hello Eric and Andreas,

My problem is that the arrowkey is hold down and not being pressed
quickly several times.
So there is no keyup.
Or do I not get what you mean?

The flushEvents doesn't work either :-(

greetings,

William



2008/9/27 Andres Martinez <andres at bakno.com>:
> Hello William
>
> An easier way to use the arrow keys is whit the "arrowKey" handler. But
> unfortunately it keeps being sent while the key is pressed.
>
> What you need is a way to check for the key being released. The following
> code will do the trick
>
> ON arrowKey theKey
>   if (theKey = "Right") and (not pressed) then
>     move img "dummy" relative 30,0
>      put true into pressed
>   end if
> END arrowKey
>
> ON rawKeyUp keycode
>   if keycode = 65363 then put false into pressed
> end rawKeyUp
>
> Regards,
> Andres Martinez
> www.baKno.com
>
> On Sep 27, 2008, at 7:32 AM, William de Smet wrote:
>
>> Hello all,
>>
>> For my little son (4 years of age) I am making a little car game in
>> which he can move a car around the screen using the arrowkeys.
>> I made a few obstakels (walls) so he has to move around them but when
>> he hits them he is send back to the beginposition.
>> Not to difficult for me to make :-)  and a lot of joy for him!!
>>
>> But now I found a 'bug' in my own game :-(
>> When you keep the arrowkeys pressed down (instead of just one press)
>> and hits an obstakel there is now hit and he is not send back to the
>> beginposition.
>> How do I prevent this?
>>
>> I use the following:
>> if theKeyNumber is 65363 --rechts
>> then move img "dummy" relative 30,0
>>
>> if intersect (img "dummy", grc "muur")
>> then send mouseup to btn "start" -- btn start send the car beck to its
>> beginposition
>>
>> Thanks!
>>
>> William
>> _______________________________________________
>> use-revolution mailing list
>> use-revolution at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-revolution
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>



More information about the use-livecode mailing list