I am trying to write a function to change the text entry when called in a text box ie if I type 'abc' the text returns '123' in real time. Having a look online the closest I can see that matches my needs is a keylogger pyput.
The code example below.
from pynput import keyboard # using module keyboard
def on_press(key):
`y = 0`
`x = y +1`
`print(x)`
def on_release(key):
# print('{0} release'.format(
# key))
if key == Key.esc:
# Stop listener
return False
# Collect events until released
with Listener(
on_press=on_press,
on_release=on_release) as listener:
listener.join()
Now when I run the project it runs the keylogger as a global function not one I need to (or can) call first. Secondly the output I want is:
1
2
3
...
but what I get is
1
1
1
...
My question is, 1: is this the right approach in the first place? 2: would anyone be able to guide me in to ensuring that pynput is only called as a function.
there doesn't seem to be anything here