what I want to ask is what if I want to create the logic for the button

hello everyone, can you help me, I want to create a logic for a button and a global variable... what I want to ask is what if I want to create the logic for the button, if the condition of the button is pressed continuously then the variable will increase and if the button released then the variable will stop...

Use the touch down and touch up event for a button. Start a clock timer on touch down, which will add 1 to a counter, say every second. Stop the clock timer when you release the button - touch up event.

Example blocks:

image