Code to read mechanical keybaord pressure

Hi this is my first post.

Im working in one University project. I want to read the pressure of one key on my mechanical keyboard. So if the user press one key slowly shows one number but if press hard to the bottom will shows another.

Do anyone know how to get this messures?

thanks and regards

You need a sensor that gives analog values, not only a digital on/off signal. Analog Hall sensors may be useful, or inductive sensors.

What sort of "mechanical keyboard"? Piano? Organ? Typewriter? Something else?

Probably the most common way to read touch velocity (which is NOT the same as pressure) is to have two contacts so one is reached before the other and read the time difference between them.

If you really need final pressure (usually known as "aftertouch") then that's a very different matter.


Thanks for the response.

I was thinking of using a mechanical computer keyboard ( I'd noticed that although the technology is very old, a reading of the magnitude of these devices was never 'carried out'.

I already started with pressure sensors. They works but the big problem is the amount of sensors that can be connected before a 'tangle' all cables. Thats why I think in this idea use one hardware that was created with this porpouse

That photograph looks like an electronic keyboard.
It is not going to give you pressure readings for keystrokes.
You are going to have to be clearer about what you are trying to do.

I have to say that my intial impression is that it is not going to be possible to retrofit any existing keyboard to give pressure readings, even a mechanical one unless it is already designed to do that.

Speed or force detection requires computational power, because the course of an analog signal is important over time. Eventually 6 analog hall keys or light barriers can be handled by a single controller, generating attack and decay values for each pressed key. All controllers of a keyboard can feed the same (I2C...) bus with the pressed keys and parameters.

@DrDiettrich's response has made me think of one way you might possibly do this. If you use an old mechanical typewriter then all the keys fly towards the same point before striking the paper. If you could somehow mount a light barrier or other sensor there then maybe you could measure the speed of a key just before it strikes.

That would still leave you with the problem of knowing which key had been pressed and also if keys had been used in combination such as "shift" to get capitals.

So if the user press one key slowly shows one number but if press hard to the bottom will shows another.

Are you looking to sense pressure or short press/long press actuation?