I just started using Python's keyboard module. I was exploring with the code below until there was a error occurring at the end on line 5. The goal of the code below is to detect if I pressed the "a" on my keyboard. I attempted to put a semicolon at the end of the print function, and I tried to replace the print("A") with pass and break but Python gave me the same error as before.
import keyboard
while True:
try:
if keyboard.is_pressed('a'):
print("A")
Output:
File "c:\users\emma\mu_code\keyboard.py", line 6
Syntax Error: unexpected EOF while parsing
Why do I have this syntax error and how can I get rid of it?