I need to do the keyboard detect
crazyCoder691 (6)

first off, I use "</>" to detect code
I always use the code in python:
if keyboard.is_pressed(this key)
"do this"
it simply does not work on my repl.
I'm trying to do this:
print("1. Play a new game")
print("2. Play a 1-Player version(using random variable)")
print("3. How to Play")
print("Type Option:")
if keyboard.is_pressed("1")
from twoplayer import play
the "twoplayer.py" is a file that I have already made with a function called play. If it works it should print hello
this is the code in twoplayer.py
def play():
I am getting this error about invalid syntax on the if keyboard.is_pressed(1) line!!! This worked perfectly on IDLE!!!
Does anybody have an alternative?

You are viewing a single comment. View All
crazyCoder691 (6)

So, I can't find this code in my Repl's, but I did some research and figured that the function :


all I needed to do was:

keyboard_press = input() #create a variable
if keyboard_press == '1':
    do this
elif keyboard_press == '2':
    do this other thing

this worked perfectly for anyone who needs an answer