Trap/script for arrow keys?

Scott Rossi scott at tactilemedia.com
Thu Mar 6 16:14:01 EST 2003


Recently, "Judy Perry"  wrote:

> 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?


You could use the arrowKey message:

on arrowKey tKey
  switch tKey
    case "left"
    # your move script
    break
    case "right"
    # your move script
    break
    # etc.
  end switch
end arrowKey
    

Regards,

Scott Rossi
Creative Director
Tactile Media, Multimedia & Design
-----
E: scott at tactilemedia.com
W: http://www.tactilemedia.com




More information about the use-livecode mailing list