Use Grove - Mech Keycap as a mechanical tally counter

I wish to use Grove - Mech Keycap as a mechanical tally counter (https://en.wikipedia.org/wiki/Tally_counter), is it possible to (I wish to count the number of clicks until 99 and then it will reset for new counting)?. If yes, I will appreciate a lot a simple example code. Thanks