I am interfacing four keys. I am using pull-up resistor for it. So that pins are high when switch is open & low when switch is pressed. I took reference from mazidi & made keypad routine in C & works fine for me. Mazidi gave 4x4 keypad algo & I used it to work for individual switches on four pins. With every press one variable is incremented. With few more tweaks I am able to detect single click & if key is kept pressed then input gets incremented fast. Now I wanted to learn how I can implement difference between single & double click. keys pressed for short time & keys pressed for long time. 1. Any reference algo for it.