counting button presses with LCD display

If possible can someone offer some guidance
I would like to count button presses and display them on an LCD.
I believe I can figure the display part but at this point need some pointers on the counting

If button pressed
Inc counter
Display on LCD

If button still pressed, loop until released.

Continue after button released

The button should be connected to the digital input and Gnd with a 10k R to 5v.


The IDE has an example called "state change detection" (digital examples) that might do what you want.

found it and the project works