Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pynput.keyboard not functioning #623

Open
trhh07 opened this issue Jan 1, 2025 · 3 comments
Open

pynput.keyboard not functioning #623

trhh07 opened this issue Jan 1, 2025 · 3 comments

Comments

@trhh07
Copy link

trhh07 commented Jan 1, 2025

I am trying to implement pynput into a script that read a word that is typed and replace it with an encoded version after space is pressed and while the listening is working perfectly it is not executing any command to take control over keyboard. I also tried this in a blank python file with just a pynput.keyboard tap function and it was not working.

I do not know if this an issue with my OS (MacOS), IDE (Pycharm Pro) or the PYPI install.

I have read through documentation and other similar issues logged on github and I can't find any solutions except for the idea of there being a missing dependency on the install but the user did not provide what the dependency that was missing was and I cannot find a list of dependencies to work this out myself.

@moses-palmer
Copy link
Owner

Thank you for your report.

Can you provide a small sample script and a more thorough description of the problem? Does nothing happen when you use the keyboard controller, or does an error occur?

@trhh07
Copy link
Author

trhh07 commented Jan 18, 2025

Hi,
The script was just the example script in the documentation:

from pynput.keyboard import Key, Controller

keyboard = Controller()

# Press and release space
keyboard.press(Key.space)
keyboard.release(Key.space)

# Type a lower case A; this will work even if no key on the
# physical keyboard is labelled 'A'
keyboard.press('a')
keyboard.release('a')

# Type two upper case As
keyboard.press('A')
keyboard.release('A')
with keyboard.pressed(Key.shift):
    keyboard.press('a')
    keyboard.release('a')

# Type 'Hello World' using the shortcut type method
keyboard.type('Hello World')

and it didnt produce any error it just did not output anything and it stopped running

@moses-palmer
Copy link
Owner

Just to quickly check whether this could be an issue with the receiving application: could you insert the statement import time; time.sleep(5) at the top of the script, run it and then quickly switch to a window accepting keyboard input, such as a text editor where pressing A would insert the letter?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants