What linear sensor for a keyboard?
Most keyboards simply use two contacts per key, configured so that they close (or open) at different positions in the key's travel. They estimate velocity from the time that elapses between the two events. Even the fancy weighted "piano action" keyboards use this basic sensing method.

Trying to measure position and/or velocity directly sounds like massive overkill.