Is it possible to use the same key when replacing a door knob?
Most brands of locks can be re-keyed, but it usually requires specialized techniques and sometimes tools. Many retailers will do it in-house free or for a small fee. Otherwise, any locksmith* should be able to help you out.
Be aware that keys have brand-specific cross-sectional shapes, so be sure to buy a new lockset of the same brand (or compatible with) the old one.
* I'll concede that locksmiths may have a slightly higher than average rate of crookery among them, but it goes without saying that any company performing service on or involving your home should be vetted properly. Any implies any reputable locksmith.