Anvil Studio is great tool for recording MIDI from you music keyboard.
For recording your music from MIDI capable instrument like piano or keyboard, you need a MIDI-to-USB cable. For example Yamaha UX16 works fine (photo). Some instruments do provide USB connection, and then USB cable is sufficient.
It is possible to edit and create MIDI files without external instrument.
The first look might be a little confusing due to amount of information.
For recording, first check that the correct devices are visible and defined in AnvilStudio in menu option View->Synthesizers. Then simply use REC and STOP buttons for recording. After saving you music, you can later edit and cut&split your songs into separate files.
You can even program certain instrument keys for starting and stopping recording.
There are many features that I never used, but might be interesting like Transponse, Practise etc.