MagSafe supports my 'entire phone' bouncing around in my truck, and hanging on my headboard at night - it's more than strong enough to hold a phone to a keyboard.
Is this something that has changed with the newer phones? I have an iPhone 12 pro, and MagSafe barely holds the wireless charging circle to the back of the phone.
lightly holding the charger in place well enough to maintain contact yet easily removed if the cable is pulled without damaging cable or device. anything after that is bonus and outside the scope of magsafe's use. the magnets on my desktop multi-device charger do not meet that requirement as they are significantly stronger than Magsafe connections.
It works great to support the entire weight of the phone on your desk or a dashboard, even when driving a fast car or riding a bike (unless you crash of course). But it's 1-2 orders of magnitude less force than required to resist pulling it out of your pocket.
I use the MagSafe Apple wallet and often turn is sideways to give myself something to hold while I watch videos in landscape. A keyboard would work in much the same way, in terms of what it needs to support and where it’s being held.