detecting for how long a key is being pressed
J. Landman Gay
jacque at hyperactivesw.com
Tue Sep 6 17:39:09 EDT 2005
oh.l at mac.com wrote:
> hello: i am trying to measure how long a certain key is being pressed
> by the user. how can i do this in runrev? thanks! olli.
See the "keydown" and "keyup" messages in the dictionary, as well as the
"rawkeydown" and "rawkeykup" messages. You can get the milliseconds when
a key goes down and store it in a script local variable. Then get it
again when the key goes up, and subtract the difference between the two
to give you the duration of the keypress.
Note that on Mac OS a "keyup" message is sent by the OS immediately
after "keydown" regardless of whether the user has released the key or
not, which means you can't time keypresses on that operating system. It
works okay on Mac OS X though.
--
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
More information about the use-livecode
mailing list