Hi,
I have made a small framework for doing event driven scripts.
The idea is that the camera by default will work as normal as possible, but the user can define callbacks for button press and release and script_hooks (
http://chdk.wikia.com/wiki/Script_Shooting_Hooks)
The framework is in the events.lua file. The daemon.lua provides an example of its use.
Enjoy, and feel free to ask or suggest.
Best regards
HrClausen