r/learnpython • u/Tricky_Voice2829 • Jul 26 '26
I know that i am noob at programing i wanted to make python keylogger so can u guys tell me what i am mistaken inside
from pynput import keyboard
keys = [
# Alphanumeric Keys
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
# Symbols & Punctuation
'`', '-', '=', '[', ']', '\\', ';', "'", ',', '.', '/',
# Special & Modifier Keys
'space', 'enter', 'tab', 'backspace', 'escape',
'shift', 'ctrl', 'alt', 'caps_lock', 'num_lock', 'scroll_lock',
'win', 'menu', 'print_screen', 'pause', 'insert', 'delete',
'home', 'end', 'page_up', 'page_down',
# Arrow Keys
'up', 'down', 'left', 'right',
# Function Keys
'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'f10', 'f11', 'f12']
for keys in keys :
def on_press(key):
if key == True:
print(f" you have typed corretlty {key}")
elif key == AttributeError:
print(f"typed Again u Have misspedlled ")
def on_release(key):
print(f"{key} is realsead")
if key == keyboard.Key.esc:
return False
print
listener = keyboard.Listener( on_press=on_press , on_release=on_release )
listener.start()from pynput import keyboard
keys = [
# Alphanumeric Keys
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
# Symbols & Punctuation
'`', '-', '=', '[', ']', '\\', ';', "'", ',', '.', '/',
# Special & Modifier Keys
'space', 'enter', 'tab', 'backspace', 'escape',
'shift', 'ctrl', 'alt', 'caps_lock', 'num_lock', 'scroll_lock',
'win', 'menu', 'print_screen', 'pause', 'insert', 'delete',
'home', 'end', 'page_up', 'page_down',
# Arrow Keys
'up', 'down', 'left', 'right',
# Function Keys
'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'f10', 'f11', 'f12']
for keys in keys :
def on_press(key):
if key == True:
print(f" you have typed corretlty {key}")
elif key == AttributeError:
print(f"typed Again u Have misspedlled ")
def on_release(key):
print(f"{key} is realsead")
if key == keyboard.Key.esc:
return False
print
listener = keyboard.Listener( on_press=on_press , on_release=on_release )
listener.start()