Page 1 of 1

Function on Keypress hold

Posted: Sun May 27, 2018 9:50 pm
by aircooled76
Hi Guys,

I am looking for a way to have a process (video cut) to happen when the "a" key is pressed but a different process (video fade) to happen if the "a" key is held down for a period of time (say 50ms.)

I have been looking at the keysdown function and making a repeat loop but I can't get anything to trigger with the keysdown function when the key is pressed.

Any help appreciated.

Code: Select all

on keyDown theKey
   if theKey is "a"
   
   then
      answer "a"
      
      if "a" is in the keysdown
      then
         answer "a is down"
      else 
         
      end if
   end if
end keydown

Re: Function on Keypress hold

Posted: Sun May 27, 2018 10:31 pm
by jmburnod
Hi,
It seems you need do something with keyup
period of time (say 50ms.)
50 seems short
Something like that:

Code: Select all

local sStartTime
on keyDown theKey
   put the milliseconds into sStartTime
end keydown

on keyup theKey
   if pKey = "a" then
      if the milliseconds < (sStartTime + 50) then
         doVideoCut
      else
         doVideoFade
      end if
   end if
end keyup
Best regards
Jean-Marc