Trap/script for arrow keys?

Judy Perry jperryl at ecs.fullerton.edu
Thu Mar 6 15:56:01 EST 2003


Here's my stupid question of the day:  How to trap for the arrow keys and
rescript their behavior to move a graphic (in this case, I used a button)
about the screen?

Here's what didn't work:

on keydown whichkey
global theXcoord, theYcoord
if whichkey = numToChar(30) then   -- up arrow key?
  subtract 10 from theYcoord
  set the loc of btn "Fish" to theXcoord,theYcoord
end if
if whichkey = numToChar(31) then   --down arrow key?
add 10 to theYcoord
  set the loc of btn "Fish" to theXcoord,theYcoord
end if
if whichkey = numToChar(28) then  --left arrow key?
subtract 10 from theXcoord
  set the loc of btn "Fish" to theXcoord,theYcoord
end if
if whichkey = numToChar(29) then  --right arrow key?
add 10 to theXcoord
  set the loc of btn "Fish" to theXcoord,theYcoord
end if
end keydown

Perhaps this maps differently on a windows or unix machine, but I think
that these are the correct mac keyboard numbers (from the Danny Goodman
book) but when I try "answer numToChar(28)" in the message box it gives me
other characters.

Any suggestions?

Thanks!

Judy





More information about the use-livecode mailing list