Keyboard input monitor tool - 'keeylogger'
Index
- Overview
- What This Script Does
- Features
- Output File
- Installation
- How to Run
- Usage Example
- Important Notes
- Troubleshooting
- Contact & Support
Related Links:
Overview
This is a lightweight keylogger script that captures and logs typed text in a formatted manner. Instead of logging raw key events, it captures actual readable text that the user types, making it easy to review what was typed.
What This Script Does
- Captures typed text: Records characters as they are typed
- Handles special keys: Properly handles Space, Enter, and Backspace keys
- Removes formatting noise: Ignores modifier keys (Shift, Ctrl, Alt, etc.)
- Line-based logging: Logs each line of text when Enter is pressed
- Graceful exit: Press ESC to stop the logger and save any remaining text
- Timestamp logging: Each logged entry includes a timestamp
Features
| Feature | Behavior |
|---|---|
| Regular typing (a-z, 0-9, symbols) | Captured as-is |
| Space key | Adds a space to the buffer |
| Enter key | Logs the complete line and starts fresh |
| Backspace key | Removes the last character (simulates real deletion) |
| ESC key | Stops the logger gracefully |
| Other special keys (Shift, Ctrl, Alt) | Ignored (not logged) |
Output File
The script logs all captured text to kiLikho.txt in the same directory. Each entry includes a timestamp.
Example Log Output
2026-03-04 14:23:45,123: Hello World
2026-03-04 14:23:52,456: This is a test
2026-03-04 14:24:10,789: Python keylogger demo
Installation
Prerequisites
You need Python 3.6+ and the pynput library.
Windows
- Install Python (if not already installed):
- Download from https://www.python.org/
- During installation, check “Add Python to PATH”
-
Install pynput library:
pip install pynput -
Verify installation:
python -c "import pynput; print('pynput installed successfully')"
Linux (Ubuntu/Debian)
-
Install Python and pip:
sudo apt update sudo apt install python3 python3-pip -
Install required dependencies (for keyboard monitoring):
sudo apt install python3-tk python3-dev -
Install pynput library:
pip3 install pynput -
Grant keyboard monitoring permissions (required for listening to keyboard events):
sudo usermod -a -G input $USERThen log out and log back in for changes to take effect.
Linux (Fedora/RHEL)
-
Install Python and pip:
sudo dnf install python3 python3-pip -
Install required dependencies:
sudo dnf install python3-devel libxcb-devel libxkbcommon-devel -
Install pynput:
pip3 install pynput -
Grant keyboard monitoring permissions:
sudo usermod -a -G input $USER
How to Run
Windows
Option 1: Command Prompt
python keeyLogger.py
Option 2: PowerShell
python keeyLogger.py
Option 3: Using Python virtual environment
# Activate virtual environment (if you have one)
.\myenv\Scripts\Activate.ps1
# Run the script
python keeyLogger.py
Linux
Option 1: Terminal
python3 keeyLogger.py
Option 2: Using Python virtual environment
# Activate virtual environment (if you have one)
source myenv/bin/activate
# Run the script
python3 keeyLogger.py
Option 3: Run as background process
nohup python3 keeyLogger.py &
Option 4: Run with sudo (if permissions issue occurs)
sudo python3 keeyLogger.py
Usage Example
Step-by-step Guide
-
Open terminal/command prompt in the script directory
- Run the script:
- Windows:
python keeyLogger.py - Linux:
python3 keeyLogger.py
- Windows:
-
The script is now active and listening to keyboard input
- Start typing - your text will be captured:
- Type: “Hello World” and press Enter → Logged
- Type: “Testing 123” and press Enter → Logged
- If you make mistakes, Backspace works correctly
-
To stop the script: Press the ESC key
- Check the log file: Open
kiLikho.txtto view captured text
Sample Session
> python keeyLogger.py
# Script is running, listening for keystrokes...
# You type: "Hello World" [ENTER]
# You type: "My name is John" [ENTER]
# You type: "Python is fun!" [ENTER]
# Press ESC to stop
> cat kiLikho.txt
2026-03-04 14:23:45,123: Hello World
2026-03-04 14:23:52,456: My name is John
2026-03-04 14:24:10,789: Python is fun!
Important Notes
⚠️ Legal & Ethical Considerations:
- This script captures keyboard input system-wide
- Use only on your own devices or with explicit permission
- Unauthorized keylogging is illegal in most jurisdictions
- Always comply with local laws and regulations
Troubleshooting
Issue: “pynput not found” error
Solution: Install pynput
# Windows
pip install pynput
# Linux
pip3 install pynput
Issue: Permission denied on Linux
Solution: Add user to input group
sudo usermod -a -G input $USER
# Log out and log back in
Issue: Script doesn’t capture keyboard input
Causes:
- Press ESC to stop and restart
- Check if another application is consuming keyboard events
- Try running with elevated privileges (sudo on Linux)
Issue: Unicode/Special characters not captured
Solution: This is a limitation of pynput’s char attribute. The script captures what key.char returns, which may vary by keyboard layout.
Contact & Support
For issues or questions, refer to:
- pynput documentation: https://pynput.readthedocs.io/
- Python documentation: https://docs.python.org/
Version: 1.0
Last Updated: March 4, 2026
Compatibility: Python 3.6+, Windows, Linux, macOS (with pynput)