KeyDown only firing once
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Livecode Opensource Backer
- Posts: 9383
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
KeyDown only firing once
What code can I use to stop multiple firing of a key when my finger gets stuck on it?
Re: KeyDown only firing once
Maybe checking the last character in your field or wherever you type.
If it is the same as the currently pressed char...
If it is the same as the currently pressed char...
-
- Livecode Opensource Backer
- Posts: 9383
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: KeyDown only firing once
Not possible when the keyDown is being used for moving a graphic object round a stack in a game.
Re: KeyDown only firing once
True!
Maybe you can post your script?
Maybe you can post your script?
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: KeyDown only firing once
Hi friends,
If i understand correctly the goal, this script does the job
Kind regards
Jean-Marc
If i understand correctly the goal, this script does the job
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
Jean-Marc
https://alternatic.ch
-
- Livecode Opensource Backer
- Posts: 9383
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: KeyDown only firing once
No, I am afraid that does not work:
- -
cardScript:
A lot of that 'guff' after the switch statement is for the 'ant' to 'eat' things.
- -
cardScript:
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
- Attachments
-
- Ant Maze END.livecode 2.zip
- Here's the stack.
- (197.97 KiB) Downloaded 97 times
Re: KeyDown only firing once
AHA, and where is the KEYDOWN handler in question?
-
- VIP Livecode Opensource Backer
- Posts: 9657
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: KeyDown only firing once
Can you use "keyUp" to do what you want? That method cannot get "stuck"
Craig
Craig
-
- Livecode Opensource Backer
- Posts: 9383
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: KeyDown only firing once
Ouch! That's simple.
BUT, better to use rawKeyUp as one can trap the arrowKeys that way.
UP = 65362
LEFT = 65361
RIGHT = 65363
DOWN = 65364
BUT, better to use rawKeyUp as one can trap the arrowKeys that way.
UP = 65362
LEFT = 65361
RIGHT = 65363
DOWN = 65364
Re: KeyDown only firing once
Hi !
Maybe the flushEvents can be of some help too..?
flushEvents : "Clears pending events from the event queue so they will not trigger handlers.!
Sincere
Thunder.
Maybe the flushEvents can be of some help too..?
flushEvents : "Clears pending events from the event queue so they will not trigger handlers.!
Sincere
Thunder.
-
- Livecode Opensource Backer
- Posts: 9383
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: KeyDown only firing once
flushEvents
Quite possibly, but not for 9-14 year olds who have been programming for less than 2 weeks.
Quite possibly, but not for 9-14 year olds who have been programming for less than 2 weeks.