Here is my tutorial for key detection in python! Using readchar, we can detect and interpret key presses in python, without having to press enter after key presses.
I have created a demo / example project demonstrating this. Below is also a step by step guide for how you can do this too.
Here's how:
1) Importing readchar from readchar import readchar
2) Creating your variable your_variable_here = readchar()
3) Input and keypress functions
if your_variable_here == '1':
#1 - First Keypress
print("Hello, World!")
elif your_variable_here == '2':
#2 - Second Keypress
print("Your Awesome!")
else:
#If input != '1' OR '2'
print("Invalid Input")
That's it.
These are the basics, you can add more functions and change what you want. This was just meant to be a simple guide to get you started.
If you would like to see a slightly more complex example of this see @52eagle's post:
Hello fellow programmers,
Here is my tutorial for key detection in python!
Using readchar, we can detect and interpret key presses in python, without having to press enter after key presses.
I have created a demo / example project demonstrating this. Below is also a step by step guide for how you can do this too.
Here's how:
That's it.
These are the basics, you can add more functions and change what you want. This was just meant to be a simple guide to get you started.
If you would like to see a slightly more complex example of this see @52eagle's post:
https://repl.it/talk/share/Arrow-keys-and-such-using-from-readchar-import-readkey/28853?order=votes
If you need further help or have any suggestions, feel free to put them in the comments. I'll be giving everyone cycles :)
I'm quite new to python too so feel free to give me any tips or advice that could help me improve.
@Reuben123 is it possible to detect clicks ??