A good microphone, practice, and using the metronome. A good mic for a good price is the Shure SM-57 - it's actually widely used in studio recording, often for drums. But it's key feature is that it has a very accurate signal, whereas other mics are more about how they color the sound.
So, for accuracy and quality, it's pretty good for a hundred bucks. You'll need a DAC to go with it. I've got a scarlet 2i2, but there are other models to look into. I'd have gone with the SM-57 first if I had known about its reputation over the past 60 years. SM58 is also solid.