Exiting a function on a key press.

i am also very much into Light Painting. Would love to see some of your photos? =)

What kind of camera are you using?
If you are using a Canon DSLR there is some "non-canon" softwares - i use Magic Lantern - which will really extend your camera's functions. I use a LOT of these new functions in my light paintings, like the intervalometer or the "movement trigger"...
It worth to check out: http://www.magiclantern.fm/

maybe there is something similar for the other camera manufacturers.

How is your project going?

Good luck!
=)