2

I have a loop that make a Zigzag Shape and I Want to Stop this Loop when any Key Pressed

I want to stop the zigzag loop when I press any button from the keyboard (not a specific button like "Space" etc. Because I see many Articles that Use a specific Key I don't want that I want any button from the keyboard)

while True:
print("*****")
print(" *****")
print("  *****")
print("    *****")
print("     *****")
print("   *****")
print("  *****")
print(" *****")
print(" *****")
print("*****")
  • 1
    It seems that this is easy to do with the `keyboard` python package. Are you willing to use modules that don't come with the standard distribution? – Ben Grossmann Nov 13 '22 at 23:31
  • 1
    Also, are you specifically looking to make this pattern in the standard out (i.e. with print statements), or would a tkinter gui be acceptable? – Ben Grossmann Nov 13 '22 at 23:35
  • @BenGrossmann Can You till Me how to Use keyboard in this Example? and About Tkinter NO , I want to Use print Function BUT if this Example Can be Made with Tkinter SO can You Help Me ? – Mazen AboBakr Nov 14 '22 at 10:47
  • See [this post](https://stackoverflow.com/a/57644349/2476977). I believe something like `if keyboard.read_key(): break` should work, but I don't have the module myself to test this out. – Ben Grossmann Nov 14 '22 at 12:38

0 Answers0