The begiiner's guide to millis() is a place to start to learn about non-blocking timing. Another tutorial that will help is the state change detection tutorial. That will show how to detect when the button becomes pressed or released (as opposed to when the button is pressed or released). In other words, you look for the transition, not the level. So, when the button becomes pressed, save the time (millis()) in a variable and, in loop(), check if the button is still pressed and the difference between the current millis() and the recorded millis(). If the button is still pressed after 5000 milliseconds turn on the LED.
The buttons I am using is "capacitive touch" buttons. I need to make sure that someone doesn't press a button by mistake, so the solution is that they need to press it for at least 3 seconds before it respond. But if the button is "unpressed" the servo or LED must go to a previous state. and there are 16 buttons on the panel.
Is there any way not to repeat the code over and over for every button??
I didn't say its wrong.. in my sketch there is an error.. don't know how to solve it yet.. Sorry.. I did not mean to be rude... I'm new at this... relax please...