The state change detection example shows you how to determine when the switch BECOMES pressed, rather than IS pressed, or BECOMES released. Based on the time when the switch becomes pressed and when it becomes released, you can determine how long it was pressed.
Does a long press count as a press, too?