This is why I use a right angle connector cable and gaffer tape the cable to the back or bottom of the keyboard. It’s fugly but it prevents this exact problem.
Magnetic connectors work well in this case, and you won't need that tape. But if you move your keyboard around a lot they might be a slightly worse solution than yours ;-)
My work keyboard has a cheap magnetic cable so I can easily plug and unplug it (I'm not leaving a custom mech unsupervised a work!). It indeed takes most of these strain.