Please be more specific. This question is much too vague for anyone to help you.
It would be child's play to create a simple shell script that responds to a keystroke, then run it in the background using standard UNIX execute behavior, specifying background (&).
Is this what you want? Or do you want something in Cocoa? Objective-C? Perl? C? C++?