Keyboard is a general term for electronic instruments and devices played or entered with keys. They handle not only piano sounds but also synths, organs, strings, and many other timbres.
The basic idea
The layout of the keys is the same as a piano, but the way the sound is produced is different. A MIDI keyboard has no sound engine of its own; it sends performance data to a DAW or a software instrument.
How to use it when playing and programming
The uses vary widely: playing chords, entering melodies, or tapping in drums as if hitting pads. Combined with the piano roll, you can edit your playing afterwards.
How it differs from related terms
A piano is a specific instrument, while keyboard is a broader word that includes electronic keyboards and input devices.
Playing the same phrase while switching sounds shows you how wide a range of roles a keyboard can cover.
