Implement a simple digital Stopwatch, which will display the time elapsed in seconds and minutes, as described below.
Please read both Display and Controls sections !
Time elapsed, should be displayed in the
by replacing the previously displayed time string "in-place"
(clearing the whole or a part of the screen is also allowed).
The stopwatch must be updated at least every second.
0 minutes, 0 seconds
0 minutes, 33 seconds
1 minute, 50 seconds
Initially, you can start with '00:00' or with any other value in range [00:00-59:59].
Once your Stopwatch reaches
59:59, it should reset to
00:00 and continue afresh.
You can use a different base (instead of decimal) or even a different numeral system if you wish, as long as you follow the general pattern.
13:03 can be displayed as:
Beware that if you use a non-decimal numeral system/base, it must be encoded using printable ASCII (or Unicode) characters, e.g. using two binary (unprintable) bytes for minutes and seconds is not allowed.
You must also left-pad your output with zeroes as appropriate, if your numerical system allows for that.
Replacing the separator character
: with any other printable character (including digits) is also acceptable.
The stopwatch should start paused, and stay in this state, until user explicitly starts it, by pressing the 'control' key (see below).
If, while stopwatch is counting, user presses the 'control' key again, the stopwatch should pause (keeping the current time), until the 'control' key is pressed a one more time.
The 'control' key can be a single keystroke, e.g.
or any combination of keys, e.g.
Ctrl+Shift+X, but it must be 'atomic', pressing multiple keys in sequence, e.g.
Enter, is not allowed.
The same 'control' key (or combination) must be used to pause and resume the stopwatch.
You must use a specific 'control' key, i.e. 'any key' is not allowed.
Alternatively, you can use a single or double mouse-click, instead of a keypress for 'control'.
- This is code-golf, the shortest answer in bytes wins;
- Standard code-golf loopholes apply;
- Your program must (theoretically) be capable of running forever.