Multikey keypad Hold Button timer

Hey guys, i am new to arduino and i am working on a program but i am hitting a roadblock. So my program is basically a keypad and what i need is to be able to know if a button has been held for longer than 5 seconds and then change the state to RELEASED (even if the button is still held down)

I am using the keypad library https://codebender.cc/example/Keypad/MultiKey#MultiKey.ino

Thanks in advance

I wonder what is the desired output of your project?

If you want to track the states of all keys, you can have an array of input (raw key) states, eventually an array of output (restricted) states, and an array of times where the time of the first keydown of each key is stored.

Other output methods can deserve more or less memory and code.