Since you're talking about the Raspberry Pi, maybe you're looking for a hardware. In this case, you can get MIDI piano keyboards that plug into the computer over USB (or can be used standalone). These can both send MIDI data to the computer and also receive it and play it with their internal synthesizer. (If you go really expensive, you can get actual grand pianos with sensors and actuators under each key, along with a subscription service that gives you access to recordings by professional piano players, replayable at your whim with exact dynamics so it's like they're in your living room.)
You can also build your own hardware and hook it up with a microcontroller; I've had good experiences with the Teensy, which is similar to an Arduino but can present itself to the computer as a USB MIDI device so you can build whatever creative/crazy instruments you want.
Should you come across a device with an actual MIDI port (a big round DIN socket with 5 pins), it's just a serial connection; you can get adaptors to convert them to USB.