1 year ago

#71128

test-img

hhhhhhhhhhh

Can I do this with a Python key logger?

I am working on a python key logger and currently if I were to type "Hello World" it would say

'h'
'e'
'l'
'l'
'o'
Key.space
'w'
'o'
'r'
'l'
'd'

I would like it to just say "Hello World" instead or at least

'hello'
'world'

here is my code:

from pynput.keyboard import Key, Listener
import logging

log_dir = "mydirectory"

logging.basicConfig(filename=(log_dir + "key_log.txt"), level=logging.DEBUG, format='%(message)s')


def on_press(key):
    logging.info(key)

with Listener(on_press=on_press) as listener:
    listener.join()

python

logging

pynput

keylogger

0 Answers

Your Answer

Accepted video resources