first of all you need to make sure you have the driver for the keyboard your using unless its plug and play comp.
next just simply plug the keyboard in to your soundcard and start sonar.
go to preferences./midi/playback and devices.
you should see your keyboard in there,make sure you put a check next to it.
hit apply/close.
insert a soft synth.
go to the track your synth is in and select the input,click the dropdown box and select your keyboard under input.
your output should be the synth.
Make sure input echo IS ON . that's important.