If you want a button or switch as an input on a microcontroller (MCU), you can use a “pullup resistor” so that the input is seen as a logical high when the (normally open) switch or button is closed.
An Arduino library for reading a button with functions for: on click, on hold, and on release. This library has software de-bouncing, the state of the pin is read at max every 5ms. That sould be ...