0

How to create a timer

I am trying to program a timer that starts when you press space and stops when you press space can anybody help

8th Apr 2019, 5:05 AM
Rich Lai
6 Respostas
+ 2
You have not specified the language. Some languages have a function that checks the system clock and reports that in a time format. That information can be used to act as a start counter when spacebar event is detected. You the do all other operations while waiting for spacebar event to happen again. When it does you check the system clock, store the end time, compare starting time to ending time. The result is elapsed time. If you are intending to display the time as a running time you would include the elapsed time compared to the starting time in the 'do while' process while the program waits for the spacebar event. I apologize for the grammar in the process I have described. I tried to make it as easy as possible to translate into any computer language. Happy codes
8th Apr 2019, 12:42 PM
Michael Williams
Michael Williams - avatar
+ 2
Since you will be using js, you can see some examples of stopwatch programs at stackoverflow.com Be sure to write your own code though. That will help you to understand what was done.
8th Apr 2019, 7:00 PM
Michael Williams
Michael Williams - avatar
0
What language?
8th Apr 2019, 5:12 AM
Fermi
Fermi - avatar
0
Sorry about that, I have not noticed that since I am a beginner. I am thinking about doing it in javascript.
8th Apr 2019, 6:47 PM
Rich Lai
0
I am trying to make a timer that like stopwatch it starts when you press space and ends when you press space. Not a countdown.. thanks
8th Apr 2019, 8:37 PM
Rich Lai
0
Ok thanks 😊👍👍👍👍
9th Apr 2019, 1:08 AM
Rich Lai