This may be a sign of boredom, but recently I’ve been taking a lot of those one minute online typing tests. They’re mostly the same. You get a blinking cursor and a line of random words. You type. You try not to make mistakes. At the end you get a WPM score.
These tests are fun, but I started to wonder: how well does typing random words quickly translate into typing actual prose quickly? Real sentences aren’t random. Typing speed isn’t just about knowing where the keys are. It’s about internalizing common patterns until your fingers can carry them out without thought1.
This reminded me of a story about Hunter S. Thompson. Early in his career, he typed out the entire text of The Great Gatsby and A Farewell to Arms. He thought this would help him internalize Fitzgerald and Hemingway’s prose styles.
Then I remembered that The Great Gatsby is now in the public domain.
Greenlight is a typing test of sorts. Or a writing exercise. Or just a nice way to change up how you engage with a book for a little bit.
I tried as much as I could to keep the text as I found it. But I did make one major change: I replaced any special characters or accented letters with their closest standard equivalents. I know this changes the meaning, but I do not expect most US users will have these characters readily available on their keyboards.
Credit of course, to F. Scott Fitzgerald.
(Greenlight does not work with virtual (mobile) keyboards or narrow screens).
Greenlight is a static website served over Cloudflare pages.
I wanted to avoid having a frontend build, so it’s just vanilla JavaScript. I doubt I followed JavaScript standards very well.
I used a CSS animation to make the 3 loading dots blink in and out at the beginning, but with the small payload of the site, I don’t know how many folks will really get to experience that.
When I started, I thought one of the challenges would be figuring out how to lazily load the text of the book. But The Great Gatsby is a pretty trim novel. And I forgot how little space text takes up on disk.
The full JSON file of the text broken up into lines is only 368KB. Even on a fairly slow connection that doesn’t seem worth breaking up. So I decided to load the whole text on startup.
Early on I didn’t bother to break the text up by line, but only by paragraph, relying on CSS to set the line length where I wanted. This mostly worked, but I noticed that as the span which identified the cursor changed, it would occasionally shift the line wrapping behavior. So I ended up breaking it down line by line when I parsed the text into JSON.
I had planned on storing bookmarks in cookies, but they don’t exactly fit there. I don’t want them to expire with a session or at a specific time. So I tried out the local storage API instead. I liked the simplicity of it, especially for something like this, where a) long term persistence is nice, b) I don’t intend to ever track user sessions on my end, and c) it’s hardly the end of the world if data is lost.
There’s one test I particularly like called problemwords.com which addresses this in a different way: it keeps track of words you’ve messed up in the past and pushes them back to you until you get them right. Kind of an ANKI for typing.↩︎