Well, Ventheny, you said "I'm thinking about buying a small electronic keyboard to use for songwriting."There are now two ways to get a new song down. You can record yourself singing it (or playing it on an instrument.) That is simple. I guess there is a lot of rock music out there which exists only in recorded form.
But if you want to produce a written copy, with a musical staff, with notes, and with lyrics that look professional, then MIDI teamed with music software is what you need.