When moving diagonally, you're applying an offset of magnitude speed in two directions at once for a total diagonal offset of sqrt(speed^2 + speed^2) = sqrt(2) * speed ≈ 1.414 * speed. To prevent this, just normalize the movement to have a magnitude of speed. You can store the offset in a vector and use scale_to_length to do so, or you can just divide the x and y offsets by sqrt(2) if a horizontal and vertical key are both pressed.