repeating key delay time

Kay C Lan lan.kc.macmail at gmail.com
Wed Aug 2 08:00:58 EDT 2006


On 8/2/06, Scott Morrow <scott at elementarysoftware.com> wrote:
>
>    Is there a way (within Rev) to adjust the delay interval between
> when the first Key message is sent and, if the user continues to hold
> down the key, the subsequent messages.


Couldn't see a way as you requested but I tried to approach this from a
different direction. The following script starts a repeat loop when the
button is 'down' and continues until the 'keyUp' message:
------------------------------------------
local tMyKeyDown

on keyDown downKey
  put true into tMyKeyDown
  put the rect of button "Check" of stack "Untitled 1" into tMyRect
  repeat until tMyKeyDown = "false"
    if (downKey = ",") then
      subtract 3 from item 1 of tMyRect
    end if
    if (downKey = ".") then
      add 3 to item 1 of tMyRect
    end if
    set the rect of button "Check" of stack "Untitled 1" to tMyRect
    wait 1 millisecond with messages
  end repeat
end keydown

on keyUp upKey
  put false into tMyKeyDown
end keyUp
----------------------------------------------------

I just tested this on a button and it nicely moves the button left (comma
key down) or right (period key down). The trick is in the 'wait with
messages' so you can capture the keyUp message.

 I'm working on adding
> arrowKey  control for a Pong type game and it would be nice to
> eliminate that normally useful lag.


Unfortunately in the quick time I whipped this up I couldn't get it to work
with the arrow keys as they didn't seem to send keyDown messages - at least
not on my Mac PB.

The smoothness of the movement is easily adjusted by varying the 1
millisecond wait and the 3 units of movement in my example.

HTH



More information about the use-livecode mailing list