I need a little help on python

Hello I’m looking for how to use the enter key instead of the e key in this program.

if keyPressed == True:

if key==“e”:

ent=1

Thank you in advance for your reply

1 Like

Welcome to the forum @Lorenzo! :grinning:

For some keys you have to check the special constants against keyCode instead of key (SHIFT or LEFT / RIGHT / UP / DOWN arrows) but this is not the case for ENTER or RETURN (it varies depending on your keyboard layout and platfform)

rect_fill = color(126)

def draw():
    fill(rect_fill)
    rect(25, 25, 50, 50)

def keyPressed():
    global rect_fill
    if key == ENTER:
        rect_fill = 0
    elif key == RETURN:
        rect_fill = 255
    else:
        rect_fill = 126

Next time, check out the “preformatted text” option when composing messages (``` ) so you can post better formatted code :slight_smile:

2 Likes

Thank you very much you can’t imagine what a bridge I am happy to have had a response so quickly! thank you :grin:

1 Like