Ask coding questions

← Back to all posts
Simulating key press with Python
ibProject

Is there a way to simulate a keypress with Python?
I looked around and found that this was a way to do it but it is not working.

Thanks

Voters
ibProject
Comments
hotnewtop
The07Coder

Hi there,
I have never used pynput library before, but when I run your code nothing seems to happen. Not sure what you are meaning to do in your program, but for an answer try looking at pynput's documentation.

On a side note, if you want to do keypress, you can simply use the input() with a parameter of text. This will not check if the user presses a key but checks if the user types enter or \n and then scans what the user typed beforehand.

I hope this helps :)
The07Coder