Mechanics aside the analog/linear hall effect sensor solution where it is placed underneath the key is capable of doing both velocity and pressure. But SiliconWizard is right that it needs calibration.
The way to do it is to determine voltage levels on which to switch state giving it three states. Assuming voltage reading is low when key is up
- Level < x, key is off
- Level > x and level < y, key is on the move so measure the time until on
- Level > y, key is on and pressure reading becomes active
I have done this in the late eighties when I worked at STEIM in Amsterdam. See:
https://www.recorderhomepage.net/history/innovations-in-recorder-design/ and search for Michael Barker. I still have "analog" pictures of this project somewhere, but would need to dig them up.
I don't know what the relation is in an actual piano key between the velocity of the hammer and the down ward motion of the key and if it makes a lot of difference in sensing the motion of either the hammer or the key to determine velocity, but I would use the underneath the key option. Feels simpler to implement.
For pressure Yamaha used to use a single bar of material where the resistance changes with pressure. It was placed underneath the keys and resulted in channel pressure and not after-touch. Meaning a single reading for the whole keyboard versus a reading per key. How modern day keyboards do this I don't know. When it is done with some pressure sensor this would most likely also need calibration of some sort.