# Reaction Timer

A one-lamp reaction timer as a handheld made of kit parts. Press Start, wait for the lamp, then hit the key as fast as you can; five tries make a round, scored on a printed scale.

Object · With a Pass · https://tactileui.dev/objects/reaction-timer

> The code and styling for this object come with the Pass. Sign in if you have one. Sign in: https://tactileui.dev/auth/sign-in The price: https://tactileui.dev/pricing

## Anatomy

Shared handheld case, Pointerdown keys, Event timestamp timing, Segment lcd digits, Concentric corners, Scale as an object

## Usage notes

A game you could hold, drawn from the kit's own parts: a moulded case with an LCD, one big lamp with a printed scale beside it, one long key, a Start key, a sound switch and a speaker grille. Press Start and wait a random second or three; when the lamp lights, hit the key. The best average is kept on the visitor's device. It shares its case with the library's other handheld games.

## Options

| Option | Type | Description |
| - | - | - |
| sound | boolean | The switch on the case. On, a press, a false start and the end of a round each have a tone once you have pressed a key (a browser allows sound only after a press). The visitor’s own setting is kept on their device. |
| label | text | What a screen reader calls the case. |

## Methods

- hooks
- update
- destroy

## States

1. **How to play**: Press Start (or S). Five tries make a round and the average is scored on the printed scale. A press before the lamp is a false start and the try is run again.
2. **Keys**: Space or Enter is the big key and holds it down while held; with no round running it starts one. S starts. Space on the sound switch flips the switch and presses nothing. Sound begins with the first press.
3. **Made of**: The kit's Panel (the case), LCD (time and best average in seven segments, five pips for the tries), Lamp (the big lamp, four scale lamps and a state lamp), Key (the long key and the primary Start key), Tray, Switch (sound) and Grille.
4. **Idle**: The time and the best read three dashes, the lamp is dark, the screen says Press start.
5. **Waiting**: The LCD says Wait and the status lamp is amber. A press now is a false start.
6. **Lamp lit**: The big lamp lights and the LCD says Now. Its time starts in the frame that draws the lamp, and a press is timed from the event's own timestamp. Left for over a second, the try is void.
7. **Result**: The time shows in milliseconds with a word for it (Sharp, Quick, Good, Slow) and the pip for that try goes on.
8. **False start**: The try does not count and is run again.
9. **Round average**: A lower average than the best is kept on this device as a new best.
10. **Sound**: A tone for a good press, a low buzz for a false start, two rising tones for the end of a round. The switch turns it off; the choice is remembered.
11. **Reduced motion**: A held key shades but does not move; the lamp still lights.
12. **Twelve finishes, two volumes**: The case reads the finish and volume tokens only: aluminium, graphite and the other ten finishes, Tactile or Quiet.

## How it works

Original. The case is the library's shared handheld (originals/components/shared/handheld), drawn from the kit's parts at one size and scaled as an object. It needs the Tactile UI Kit's stylesheets on the page; the Code tab's example links them from ./kit/.
