I could definitely write something like that in a Builder code component which would work offline and online.
Here’s a post with some of the code I’d use. Potentially each key press could be logged.
You can also see similar code working for a simple two-digit age response here: Pavlovia
Best wishes,
Wakefield