If I understand what you're wanting to do, you should be able to
1) record the keyboard's MIDI output with a DAW as you play a song,
2) clean things up if desired (i.e., fix any bad notes, quantize to make the note timings consistent, fix anything that got quantized in the wrong direction, etc.),
3) save the MIDI recording as a standard MIDI file (SMF),
4) load the SMF into a notation program to spiffy it up, and
5) save your masterpiece and print it.
Some notation programs let you enter notes from your keyboard, but often they don't operate in "real time," whereas recording the MIDI in a DAW first will let you play in real time.
There are free DAWs and free notation programs, so you don't even have to spend a dime.
A few free DAWs are PreSonus Studio One Prime, Sony ACID Xpress, Tracktion T4, and Willow Software Anvil Studio.
A few free notation programs are FORTE Notation Free, MakeMusic Finale NotePad, MuseScore, and NCH Crescendo.