Stop Repeating Keys
Sarah Reichelt
sarah.reichelt at gmail.com
Mon Jan 22 22:11:45 EST 2007
On 1/23/07, Mark Greenberg <markgreenberg at cox.net> wrote:
> I have an application where the user types in numbers, but I don't
> want the keys to automatically repeat. For instance, if the user
> holds down the 5 key too long, I don't want 5555 to appear. I am
> already capturing the keystroke with an ON KeyDown handler and
> manipulating the user's input. Using KeyUp instead causes a problem
> when two keys are pressed, so that won't work.
>
How about something like this (untested):
local sKeyPressed
on keyDown pKey
if sKeyPressed <> true then
put true into sKeyPressed
pass keyDown
end if
end keyDown
on keyUp
put false into sKeyPressed
end keyUp
When a key is pressed, it checks the flag. If it is not true, then the
keyDown message gets passed so the key will be typed. Then the flag is
set to true. Any more keyDowns will be ignored until the flag is reset
which happens on keyUp.
Cheers,
Sarah
More information about the use-livecode
mailing list