arrowKey

Bob Sneidar bobs at twft.com
Mon Dec 19 12:45:13 EST 2011


On Dec 19, 2011, at 6:51 AM, paolo mazza wrote:

> Hi All,
> how can I check if the "arrowKey up" is down or is up ?
> 
> For example, for the option Key I can write .. if the optioKey is down
> then...,  for the mouse I can write ... if the mouse is down then ...
> 
> What about  the arrow keys ?
> 
> All the best
> 
> Paolo

on arrowKey theKey
   switch theKey
      case "Up"
      case "Down"
      case "Left"
      case "Right"
   end switch
   pass arrowKey
end arrowKey

Pretty simple. You can also use the keysDown() function which will return the same codes as rawKeyDown, so write a couple simple scripts to see which codes are for which arrows. They may not be the same on all platforms tho' so test with Windows, Mac and Linux to be sure. 

In the card script put:
on escapeKey
    answer "Keysnatcher is off!" as sheet
    exit to top
end escapeKey

In a button on the card put:
on mouseUp
       repeat
           put keysdown() into theKeysDown
        if theKeysDown is not empty then
            answer theKeysDown as sheet
        end if
        wait one second with messages
       end repeat
    pass mouseUp
end mouseUp

Bob






More information about the use-livecode mailing list