This project is strictly for educational purposes to understand how keylogging works at a technical level.
WARNING: Using keyloggers to monitor others without explicit consent is:
- Illegal in most jurisdictions
- Unethical and a violation of privacy
- Potentially subject to criminal prosecution
Only use this code on your own computer for learning purposes.
This is a simple keylogger implementation in Python that demonstrates:
- Keyboard event monitoring using the
pynputlibrary - Event-driven programming
- File logging
- Real-time key capture
- Captures all keyboard input
- Logs keystrokes to a timestamped file
- Displays real-time key presses in the console
- Can be stopped by pressing ESC
- Creates organized log files in a
logs/directory
- Python 3.6 or higher
- pynput library
- Install the required dependencies:
pip install -r requirements.txtRun the keylogger:
python keylogger.pyTo stop the keylogger, press the Ctrl+C inside the console where this script is running.
- Listener Setup: Uses
pynput.keyboard.Listenerto monitor keyboard events - Event Callbacks:
on_press(): Triggered when a key is pressedon_release(): Triggered when a key is released
- Logging: All keystrokes are logged to a timestamped file with datetime stamps
- Graceful Exit: Press Ctrl+C to terminate the listener
This project helps understand:
- Operating system event handling
- Python's event-driven programming
- File I/O operations
- Security concepts and attack vectors
- The importance of input security