So what value is stored in key when the key is up?
How is construct() called? Is it in a loop in your main(), or is it called directly as a result of a completed ADC conversion event?
Finite-state machine - Wikipedia, the free encyclopedia
Basically, you have two events, key-press and key-release
You also have two states key-up and key-down
So state=key-up and event=key-press takes you to state key-down.
In state key-down, you increment your counter (at some rate).
On the key-release event, you look at the key and the counter, and decide what it all means.