Trapping multiple keystrokes

Kaveh Bazargan kaveh at rivervalleytechnologies.com
Fri Dec 1 16:16:32 EST 2017


Thanks for the replies guys.

Richmond, sorry I was not clear. It is simpler:

   - I click in a field that has a value
   - I press arrow key (up or down)
   - I want the value to change up or down in that field
      - After the value is changed, other actions are triggered, e.g.
      setting the value of a scrollbar to the same value
   - The process continues while I have the arrowkey pressed
   - As soon as I release the system is idle (except for the last arrow
   action that continues)

It is the final action I have a problem with, as dozens of arrow key
actions are held in the buffer. The number keeps increasing or decreasing
and background actions are triggered.

Here is a minimal version of the handler I have:

on arrowKey theKey
   if theKey is "up" then
      put current_value + increment into the target
   end if -- up
   if theKey is "down" then
      put current_value - increment into the target
   end if -- down
   pass arrowKey
end arrowKey



On 1 December 2017 at 20:27, 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
>



-- 
Kaveh Bazargan
Director
River Valley Technologies <http://rivervalleytechnologies.com/> • Twitter
<https://twitter.com/kaveh1000> • LinkedIn
<https://www.linkedin.com/in/bazargankaveh/>
Phone +44 7771 824 111



More information about the use-livecode mailing list