detecting for how long a key is being pressed
nicolas_cueto at yahoo.com
Tue Sep 6 17:16:50 CDT 2005
Like Jacqueline, I too was going to suggest "keyDown"
and "keyUp". However I tried it out first myself and
found that so long as the targeted key is held conti-
1. the "keyDown" message is also generated continu-
ously. Thus, if the variable for storing the start time
is being set by the keyDown handler, then that variable
will be continuously reset. (To resolve this, I tried "if
tTimeVar is not empty then" to escape the handler, but
2. the "keyUp" message is also being generated. I know
this because in the keyUp handler I have a "put x in field y"
line, which results in the field continuously blinking. (I would've
thought the keyUp message would be generated only after
the target key was released?)
Jacqueline also suggests that these key-handlers might be
system specific. In which case, I'm on Win2K.
Finally, I've appended my scripts below, in case someone
has a solution.
niconiko language school
### THE CARD SCRIPT
on keyDown s
put the long seconds into gStartTime
pass keyDown -- TRIED BOTH WITH & W/OUT THIS LINE
### THE STACK SCRIPT
on keyUp s
put the long seconds into tEndTime
put (tEndTime - gStartTime) into field "fResult" -- RESULTS IN A
More information about the use-livecode