On 4/18/05 1:48 PM, Scott Rossi wrote:

Howdy List:

Still looking for options to reliably detect keypress events on Windows with
Rev.  Recap: keyUp messages are immediately sent regardless of whether a
pressed key is released.  Same happens with keyDown and rawKeyDown.  Even
the keysDown() function doesn't seem to help here since it apparently
alternates between returning the pressed key/s and empty.

I now have to go explain to a client why I was unable to get their demo
working correctly on a test system.  This is majorly irritating since key
events work as expected on MacOS.

How can one reliably tell on Windows when a key is pressed versus when it is
released?

Are you sure you don't have your operating systems backwards? ;) In my experience, it has always been Mac OS that doesn't generate accurate keyUp messages. Windows has always worked for me. That is an OS limitation, as Macs send keyup immediately after keydown, regardless of the physical state of the key itself. Or at least, that's how it has always been in the past.


At any rate, I wrote a work-around for it, which should work just as well on Windows as it does on Macs. You'll have to alter the script to suit your own needs, but basically I had to implement a checking loop after a key was depressed. I used a rawKeyDown to start the actions I needed to do, and added "checkKey whichKey,theBtn" to the rawKeyDown handler. That started the loop. Then this handler managed the rest of it:

on checkKey whichKey,theBtn
  -- see if "f" or "r" key has been released; Macs don't generate
  -- accurate keyUp msgs so we need to use a loop check
  put charToNum(whichKey) into theKey
  if theKey is not in keysDown() then -- key is released
    repeat for each line i in the pendingmessages
      if i contains "checkKey" then cancel (item 1 of i)
    end repeat
    send "mouseUp" to btn theBtn
  else
    send "checkKey whichKey,theBtn" to me in 200 milliseconds
  end if
end checkKey

In my case, I only needed to check for the keys "r" or "f", but you could alter this to check for whatever keys you need, or all of them.

I didn't have any trouble with the keysdown() function returning incorrectly. That may be because I allowed some time between checks, but I don't know for sure.

--
Jacqueline Landman Gay         |     [EMAIL PROTECTED]
HyperActive Software           |     http://www.hyperactivesw.com
_______________________________________________
use-revolution mailing list
[email protected]
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to