Does musescore fit your needs? If you want a piano.. you should probably get a midi input keyboard. If you don’t need 88 keys and real-time playing, you can deal with less octaves.
I've never dived into this, but if electronic keyboards are just glorified midi-controllers, I'd have to think you could find a FOSS solution. If they're not simply midi-controllers, I wouldn't begin to know. I'd imagine you might have an easier time with keyboards from the 90s or whenever.
I've used Ardour to capture keyboard midi input before. Not beginner-friendly, but it works if you want to play something, pick a soundfile, edit a flubbed note or two, and add it to a project.
Not quite sure what you're after - but on the off chance, I'll mention LMMS, as I don't think it's already been mentioned amongst the other audio software.