Because of the security of iOS, it can't be done (as far as I know) without jailbreaking the device first.
Most/all of the iOS keylogging apps available on the app store are scams. If you have a device provisioned for development (not likely), there are workarounds, but Apple doesn't dig software that circumvents their security on their store. Any app they permit for sale would be easily detected and wouldn't have the necessary permissions to catch input given to another app (if the other app was engineered properly).
So the short answer is "not if it's still factory, but it can work on a jailbroken device."
Me: BH - Happily Remarried, but dealing with old stuff
<-- Betrayed iOS developer. :-)
“I'm losing my mind in a bedroom with a ghost
and I'm losing my mind in a bottle while I choke
I stayed years with you, no one knows (but I want them to).”
– Thought Industry