Count the fractions of a turn of both motors using interrupts. Speed up or slow down one or other (or both) of the motors when the fractional rotations get out of step until they are back in step again. The proper way to do this is by using a PID
Note that whether the bot moves in a straight line also depends on the tyres being the same diameter and that no slippage occurs. You can allow for different diameters in the code but not for slippage
Using a PID you could use one of the wheels as the master. The inputs to the PID would be the outputs from the two encoders, the error would be the difference between them and the output would be the PWM signal to reduce the error
so the user controls the pwm to one motor. the encoder count from that motor is used as the PID target for the other and the PID output controls the pwm of the other motor.
Think of it as the phase difference between the two. If you keep track of countA and count B, then the simple difference between the two would need to be held constant to keep the positions/rotations/RPMs the same. You could use that difference as the input to a PID and get the bias/trim you need to apply to the PWMs. You could keep that difference with simple math by adding one with every RHS forward count and subtracting one with every LHS count.
If there is strange ratio that the two need to stay at, say you have a 47/53 smaller wheel on the RHS vs the LHS, you could do something bit Bresenham-like and add 53 for one and subtract 47 for the other and use the running sum to drive the PID.
In either case, you do turns by changing the slewing setpoint of the PID.
That would make the PID's target set point a constantly-increasing value (i.e. Distance Traveled). Perhaps you should make the set point be the difference in distance traveled between the two wheels? Thus, the PID would work to drive that value to zero.
Since the phase difference between the encoders gives you the bias/trim, you could also use a throttle input to give you an ideal count/second virtual encoder, and use that to control the base PWM value to which you would apply the LHS/RHS biases.
Here's a pot-variable 2-axis control of two motors:
...but you'd add encoders and use PIDs instead of the pots to set the PWMs. Repurposing the pots to set the ideal count/sec forward/backward rate and phase change slew rate between the encoders.