Trapping multiple keystrokes

Mike Bonner bonnmike at gmail.com
Fri Dec 1 16:06:00 EST 2017


If you're using rawkeydown you can check to see if the key is actually
still down before doing any processing..

on rawkeydown  pKey
    -- since you're checking specifically for arrow keys, you can use pkey
as the first part of the filter..

if pkey is among the items of "65361,65362,65363,65364" then
   -- then determine which arrow key(s) are down and respond accordingly.
   if 65361 is among the items of the keysdown then -- left arrow key is
currently down
              --do stuff for left arrow key here
   end if

   if 65362 is among the items of the keysdown then -- up arrow key is
currently down
              --do stuff for up arrow key here
   end if
   if 65363 is among the items of the keysdown then -- right arrow key is
currently down
            --  do stuff for right arrow key here
   end if
   if 65364 is among the items of the keysdown then -- downarrow key is
currently down
            --  do stuff for down arrow key here
   end if

else
     pass rawkeydown --if a key other than an arrow was pressed, pass it on
end if

end rawkeydown

On Fri, Dec 1, 2017 at 1:27 PM, Richmond Mathewson via use-livecode <
use-livecode at lists.runrev.com> wrote:

> I may be a bit stupid, but as far as I understand you are trying to do
> this:
>
> 1. You keep an arrow key pressed down,
>
> 2. You do other things with other keys while the arrow key is pressed down.
>
> I cannot begin to try to answer your question until you either
> confirm what I have written or say that I am wrong and then
> explain, clearly, what you want to do.
>
> Richmond.
>
> On 1/12/17 10:03 pm, J. Landman Gay via use-livecode wrote:
>
>> On 12/1/17 11:52 AM, Kaveh Bazargan via use-livecode wrote:
>>
>>> I have a field with a number in it. when focused, I want the value to go
>>> up
>>> and down with the up/down arrow keys. The trouble is that if I keep the
>>> key
>>> down, it traps multiple keydown messages that continue after the key is
>>> released.
>>>
>>> How can I ensure that message are terminated as soon as arrow key is
>>> released?
>>>
>>>
>> What handler are you using? I just did a test with rawKeyDown and
>> arrowKey and they all stop when I release the key. (Though arrowkey seems
>> to be ignoring left and right keys in LC 9 for some reason.)
>>
>>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the Use-livecode mailing list