SHIFTy thoughts

Colin Holgate coiin at verizon.net
Mon Oct 11 13:10:07 EDT 2010


On Oct 11, 2010, at 12:49 PM, Richmond wrote:

> what I cannot work out how to do is find out if the SHIFT key is down without
> having to plonk my fat fingers on some other key as well.


You said this just now, with my solution that works still copied in the top of your message. Take another look:

> on checkkeys
>    send checkkeys to me in 100 milliseconds
>    put shiftkey()
> end checkkeys

You would call checkkeys at the start of your card that you want to be seeing shift being pressed, and from then on it would look after itself. Like this maybe:

global shiftisdown

on opencard
  put the shiftkey is down into shiftisdown
  checkkeys
end opencard

on checkkeys
  if the shiftkey and not shiftisdown then
       UserPressedShiftKey
  else
     if the shiftkey and not shiftisdown then
        UserReleasedShiftKey
      end if
   end if
  send checkkeys to me in 100 milliseconds
end

on UserPressedShiftKey
  put true into shiftisdown
 --do whatever you want to be done when the shift is pressed
end UserPressedShiftKey

on UserReleasedShiftKey
  put false into shiftisdown
 --do whatever you want to be done when the shift is released
end UserReleasedShiftKey


The above script would require that the user held the shift down for at least a tenth of a second for it to be seen. If you need quicker reaction than that, set the send delay to a shorter value.


  



More information about the Use-livecode mailing list