How to? Capture keystrokes?

#1
Is there a utility that will capture keystrokes, write them to a key file, to be used for repeated usage with

start AProgram & keystack /r file.key

??