Decide what it is you want to do, and how much you're willing to pay to do it. There's going to be a compromise on either end of that scale. The K10d is still a fine camera. $300-$325 used is about the average price based on Ebay completed listings (anyone here is free to check that for themselves). Refurbished means, pre-owned and cannot be sold as new. In many cases, these were returned to the factory, freshened up, some may be repaired, re-calibrated, and if you buy one from a store, they typically come with a short warranty.
The K20d is a different camera. Same body, a few of the switches and buttons were redesigned for ergonomics. In spite of popular belief, the bodies are Not identical. Same size, yes. It Has live view but they should have put the resource into something else because it sucks on the K20d. Figure on not using it. It gives you the ability to calibrate up to 20 different lenses for slight AF adjustments. I've never found this feature particularly useful because AF always seemed to be affected by lighting Type and amount. On, again, ebay completed, don't expect to put your hands on one for under about $450.
The K7 gives you an 80% (roughly) of the body size. Redesigned grip for better handling (I think) but if you have large hands, you would probably want the battery grip to go with it (same with the K5). You cannot add a grip to the Kx so if Size is of most importance, you may not like the Kx for that reason alone. Of course, the K7 does video if that's of concern. Live view is quite nice to use on the K7. HDMI output will let you see in HD whatever is on your rear screen in real time. Third party software gives back the function of tethering for most cameras so the lack of it on the K7 doesn't matter anymore. If compact, nice handling, and pro type features are your goal, not a bad starter DSLR (all of them are but this gets close to the best of both worlds). Figure on paying about $600 for a body.
Then of course, the holy grail right now is the K5. Combines the best of the entire Pentax line. Yes, it comes at a cost but IMO, worth it. Again, some changes were made to the body from the K7. They are Not identical. The AF/MF switch is changed and the mode dial is taller. Making them Both easier to use especially for those of us with large hands. I don't care what anybody says about the previous models, nice as they are, none come close to matching the Dynamic Range capability of the K5. Aside from a few hiccups at the get go, Pentax listened on this camera and gave us the features we've been asking for (video zealots aside). I don't know what the rate is right now, I'd guess around $1300.
So, How much do you want to spend, and how much camera do you want to buy? (I know nothing really about the Kx). Yes, your current lenses will work with all of them.