Here’s some sudo code for one idea of how you might do that.
variables:
boolean buttonTriggered = false
boolean idleState = true
uint8_t idleCount = 0
uint8_t timeout = 10 //seconds before going back to idle state
add to your button trigger stuff, such that any time any button is pressed these get set:
buttonTriggered = true
idleState = false
idleCount = 0 //resets count
add in main loop:
if buttonTriggered = true {
EVERY_N_SECONDS(1) //run every second
idleCount++