DEV Community

Discussion on: Text Recorder: React States, Event Handling and Conditional Rendering

Collapse
 
waelfathy2007 profile image
waelfathy

Why did you add keyup event listener instead of just capture the text and convert it to an array then loop through it then add a character to the state using settimeout

Collapse
 
ranaemad profile image
Rana Emad

Because I wanted to record the pauses between each key stroke exactly like it was written. Also, if I just pushed the new characters to the array, I wouldn't be able to maintain their position if the user went back and edited the text mid sentence.