pynput
- Run using Jupyter NoteBook or any Python IDE.
- Run the script and it will start capturing the keystrokes.
-
Just press the
Esc Key
to stop the script. -
It will create a file named
keylog.txt
in the folder from where the script is running.
on_press(key):
This function is called whenever a key is pressed. It appends the pressed key to the logged_keys list. If the pressed key is a special key (like Shift, Ctrl, etc.), it's converted to a string and logged.on_release(key):
This function is called whenever a key is released. If the Esc key is pressed, it returns False to stop the listener.
Working on it using libraries
threading
,win32gui
andpsutil
It provides functions to monitor and control the keyboard.
pip install pynput