Program stopping after executing certain lines when handling key presses

My advice when reading variable key is to apply this code:
k = key.upper() if key != CODED else keyCode

Then use local variable k instead w/ capitalized letters like the example from this link:

    k = key.upper() if key != CODED else keyCode

    if k == 'W' or k == UP:
        for f in flakes: f.vel.y -= f.maps[2]

    elif k == 'S' or k == DOWN:
        for f in flakes: f.vel.y += f.maps[2]

    elif k == 'A' or k == LEFT:
        for f in flakes: f.vel.x -= f.maps[2]

    elif k == 'D' or k == RIGHT:
        for f in flakes: f.vel.x += f.maps[2]

Ru sure that method is capitalized? If that’s a list type, it’s lower case instead: bodies.append(

2 Likes