What software or hardware are you using?
You would need a DAW to record and mix your music, some common ones are Logic, Protools, Ableton, FL studio, and Cubase. If you are using a Mac then you should have garageband already installed.
How to record though is different depending on if you're using hardware or software. You can hook a keyboard up to the computer via USB to control the software with. You can select it by going to preferences / audio & midi settings / active midi inputs