Detecting keyPresses outside of LC
Posted: Fri Oct 12, 2018 3:33 pm
This derives from a thread in this pane "Detect key events in Background", that speaks about detecting "ordinary" key presses, that is, not control keys like the optionKey or capsLock key, when LC is not in front.
It seems useful to open another thread, just so more people might see it and add to their toolbox.
In a stack with a button and two fields, in the button script:
Handlers to detect control keys are sprinkled throughout the forum, and examples can be found in the abovementioned thread.
Craig Newman
It seems useful to open another thread, just so more people might see it and add to their toolbox.
In a stack with a button and two fields, in the button script:
Code: Select all
on mouseUp
put "" into fld 2
keyDetector
end mouseUp
on keyDetector
if the commandKey is down then exit keyDetector --manually exit
put the keysDown into fld 1
if the keysDown = 120 then --detects "X"
put "X detected!" into fld 2 -- your routine here
exit keyDetector
end if
send "keyDetector" to me in 1
end keyDetector
Craig Newman