You may use a
timer. Suppose we're dealing with button
'2'
:
you need a set of states, e.g.
{ FIRST_CHOICE, SECOND_CHOICE, .., IDLE}
and corresponding symbols, e.g.
symb[FIRST_CHOICE]='a' symb[SECOND_CHOICE]='b', ..
- The user clicks the button for the first time (that is button was
IDLE
), then the timer starts, the button state becomes FIRST_CHOICE
(and you show 'a'
). - If the timer expires before further clicks then
FIRST_CHOICE
is the definitive choice ('a'
remains) and buttons state returns IDLE
. - If the user clicks before timer expiration then you put button state to
SECOND_CHOICE
(replacing 'a'
with 'b'
), kill the timer and restart it. - Perform step 3 as many times as needed passing from
SECOND_CHOICE
to THIRD_CHOICE
and so on (handling wrap around, e.g. NINETH_CHOICE -> FIRST_CHOICE
) until the user slows down OR clicks another key (that is button becomes IDLE
).