I've just started coding a little game using turtle, but my very first prototype is already very laggy.
import turtle
import keyboard
# Player 1 x and y cords
p1x = -350
p1y = 250
wn = turtle.Screen()
wn.title("Actua")
wn.bgcolor("black")
wn.setup(width=800, height=600)
wn.tracer(0)
# Player 1 Setup
player_1 = turtle.Turtle()
player_1.speed(0)
player_1.shape("square")
player_1.color("red")
player_1.penup()
player_1.goto(p1x, p1y)
player_1.shapesize(1, 1)
win = turtle.Screen()
while True:
  win.update()
  # Controlls
  if keyboard.read_key:
    if keyboard.read_key() == "esc":
      quit()
    
    if keyboard.read_key() == "d" or keyboard.read_key() == "D":
      p1x = p1x+10
    
    if keyboard.read_key() == "a" or keyboard.read_key() == "A":
      p1x = p1x-10
    
    if keyboard.read_key() == "w" or keyboard.read_key() == "W":
      p1y = p1y+10
    
    if keyboard.read_key() == "s" or keyboard.read_key() == "S":
      p1y = p1y-10
    player_1.goto(p1x, p1y)
It's probably lagging because of the "while True:" but I don't know how to improve it. Are there just too many if-statements or do I first have to set specific FPS?
Further information: I'm using VSCode, my operating system is Windows 10, my PC should normally be able to handle such a short code.
Oh, and please go easy on me with the technical terms, I'm kinda new to coding.
Edit: I just tested it again, it's definitely due to the if-statements themselves. However I still don't know how I could fix it.