How do I make a "if key press space or up or w key" kind of statement?
Posted: Thu Nov 28, 2019 7:22 pm
Code: Select all
on keyDown theKey
if theKey is space then
put -1 into birdDirection
end if
end keyDown

Questions and answers about the LiveCode platform.
https://www.forums.livecode.com/
Code: Select all
on keyDown theKey
if theKey is space then
put -1 into birdDirection
end if
end keyDown
Code: Select all
on keyDown theKey
if theKey is "q" then move button 1 relative 0,+5
if theKey is " " then move button 1 relative 0,-5
end keyDown
Parameters:
The keyName is the actual character of the pressed key.
Code: Select all
on keyDown KD
put empty into fld "fRESULT"
if KD is " " then
put "Space" into fld "fRESULT"
else
if KD is "w" then
put "w" into fld "fRESULT"
end if
end if
end keyDown
"if key space or key up or key w"
Code: Select all
on arrowKey AK
if AK is "up" then
--do something
end if
end arrowKey
Code: Select all
local birdDirection
local birdVerticalSpeed
local gameIsRunning
local citySpeed
on preOpenCard
put 1 into birdDirection
put 4 into birdVerticalSpeed
put 3 into citySpeed
end preOpenCard
on startGame
preOpenCard
put true into gameIsRunning
flapBird
end startGame
on stopGame
put false into gameIsRunning
set the bottom of button "Bird" to 400
end stopGame
// move bird up and down
on flapBird
// move bird
put the bottom of button "Bird" into newPosition
add(birdDirection * birdVerticalSpeed) to newPosition
set the bottom of button "Bird" to newPosition
// move City_Background1
put the right of button "City_Background1" - citySpeed into newLoc
if newLoc < 0 then
set the left of button "City_Background1" to the right of button "City_Background2" - citySpeed
else
set the right of button "City_Background1" to newLoc
end if
// move City_Background2
put the right of button "City_Background2" - citySpeed into newLoc
if newLoc < 0 then
set the left of button "City_Background2" to the right of button "City_Background1"
else
set the right of button "City_Background2" to newLoc
end if
//
if gameIsRunning then
send flapBird to me in 0.02 seconds
end if
end flapBird
// control bird movements
on keyDown theKey
if theKey is space then
put -1 into birdDirection
else
if theKey is "w" then
put -1 into birdDirection
end if
end if
end keyDown
on arrowKey AK
if AK is "up" then
put - 1 into birdDirection
end if
end arrowKey
on keyUp
put 1 into birdDirection
end keyUp
Code: Select all
on rawKeyDown RAWK
put empty into fld "fKEE"
switch RAWK
case "32"
put "SPACE" into fld "fKEE"
break
case "119"
put "w" into fld "fKEE"
break
case "65362"
put "UP" into fld "fKEE"
break
default
pass rawKeyDown
end switch
end rawKeyDown
seems odd as "startGame" is not standard LiveCode.on startGame
Once you've done the above steps, place the cursor where you want the picture to show up in the reply and click the "Place inline" button
Yes, but only after you have at least 10 postings!