KeyDown only firing once
Posted: Thu Jul 15, 2021 11:53 am
What code can I use to stop multiple firing of a key when my finger gets stuck on it?
Questions and answers about the LiveCode platform.
https://www.forums.livecode.com/
Code: Select all
local sStarttime,sPausetime
on opencard
put the milliseconds into sStarttime
put 500 into sPausetime
end opencard
on keydown pKey
if tTime > (sStarttime + sPausetime) then
put pkey after fld "fText"
end if
put the milliseconds into sStarttime
end keydown
Code: Select all
on arrowKey AK
put item 1 of the loc of grc "ANT" into LR
put item 2 of the loc of grc "ANT" into UD
switch AK
case "up"
set the backgroundpattern of grc "ANT" to the ID of img "A1.png"
move grc "ANT" to LR,(UD-12)
break
case "down"
set the backgroundpattern of grc "ANT" to the ID of img "A3.png"
move grc "ANT" to LR,(UD+12)
break
case "left"
set the backgroundpattern of grc "ANT" to the ID of img "A4.png"
move grc "ANT" to (LR-12),UD
break
case "right"
set the backgroundpattern of grc "ANT" to the ID of img "A2.png"
move grc "ANT" to (LR+12),UD
break
end switch
if intersect(grc"ANT",img"maze.png",4) then
send "mouseUp" to btn "RESTART"
end if
if intersect(grc"ANT",img"block.png",4) then
send "mouseUp" to btn "RESTART"
end if
--------
if intersect(grc"ANT",img"f1",4) then
add 1 to fld "SCORE"
set the vis of img "f1" to false
set the loc of img "f1" to -100,-100
end if
if intersect(grc"ANT",img"f2",4) then
add 1 to fld "SCORE"
set the vis of img "f2" to false
set the loc of img "f2" to -100,-100
end if
if intersect(grc"ANT",img"f3",4) then
add 1 to fld "SCORE"
set the vis of img "f3" to false
set the loc of img "f3" to -100,-100
end if
if intersect(grc"ANT",img"f4",4) then
add 1 to fld "SCORE"
set the vis of img "f4" to false
set the loc of img "f4" to -100,-100
end if
if intersect(grc"ANT",img"f5",4) then
add 1 to fld "SCORE"
set the vis of img "f5" to false
set the loc of img "f5" to -100,-100
end if
if intersect(grc"ANT",img"f6",4) then
add 1 to fld "SCORE"
set the vis of img "f6" to false
set the loc of img "f6" to -100,-100
end if
if intersect(grc"ANT",img"f7",4) then
add 1 to fld "SCORE"
set the vis of img "f7" to false
set the loc of img "f7" to -100,-100
end if
if intersect(grc"ANT",img"FINISH",4) then
set the vis of img "bravo" to true
end if
end arrowKey