Trapping and using keypresses
Posted: Wed Jun 19, 2013 9:39 am
Hello all,
I have a program that is used to allow my biologist colleagues to watch animal behaviour videos and record the time and nature of 'behaviours' by a simple app that allows them to start record/capture key presses/check for specific keys/end recording/save file
It has worked well for years, but need some tweaks. When I fire it up in LiveCode, it no longer works. I used to trap the key pressed and the time in a field, but now, the keypresses seem to go the first field of the app, not the one I name. Here's the relevant bits..
Advice on capturing and redirecting keypress would be most welcome. Thank you.
I have a program that is used to allow my biologist colleagues to watch animal behaviour videos and record the time and nature of 'behaviours' by a simple app that allows them to start record/capture key presses/check for specific keys/end recording/save file
It has worked well for years, but need some tweaks. When I fire it up in LiveCode, it no longer works. I used to trap the key pressed and the time in a field, but now, the keypresses seem to go the first field of the app, not the one I name. Here's the relevant bits..
Code: Select all
on mouseUp
put empty into field "data"
put empty into field "lastLine"
beep
put the milliseconds into stTime
put the seconds into disTime
put false into stopNow
put true into clockRunning
put 0 into pauseStart
put 0 into pauseStop
put 0 into pauseInterval
end mouseUp
on keyDown theKey
put the milliseconds into keyTime
subtract stTime from keyTime
subtract pauseInterval from keyTime
put value(pauseInterval)/1000 into field "date"
switch
case theKey = "?"
put "Elapsed time: " && keyTime/1000 && "s elapsed" into field "lastLine"
break
case theKey="q"
send mouseUp to button "Stop"
break
default
put "Event:" && theKey && keyTime/1000 & return after field "Data"
set the scroll of field "Data" to the formattedHeight of field "Data"
put "Elapsed time:" && keyTime/1000 into field "lastLine"
end switch
end keyDown