There are limits on how long USB cables can be, and probably limits on how long MIDI cables can be to get the maximum transfer results.
I know that my Roland UM-ONE midi cable from keyboard to pc is only 1 metre long, and vaguely recall that it's the optimum length, but maybe someone with more technical knowledge can advise.
Please be careful connecting cables. Always connect and disconnect when power is off to both pc and keyboard.
I have bitter experience of ignoring that, wrecking my old Tyros in the process. Sudden power surges are circuit board killers.