I did it again... I made another keyboard tester (posted 2021-03-16)
The other day I noticed how dirty my VT420 terminal's keyboard was, so I decided to take off the keycaps to clean them.
So I whipped up a command line keyboard tester: kbdtest.php. Save the page, rename to kbdtest.php, then run with "php kbdtest.php". Works on the Mac, haven't tested other systems.
The script draws an image of the main part of a keyboard, with the keys that should work displayed in red. Then as you type them, they're made the default color and bright or bold. Typing the same key multiple times adds and removes an underline. The first number is a count of how many different keys you've typed, the second one only counts printable characters and tab, backspace and enter. (Upper vs lower case is ignored.) When you've typed all 71 of those, the program ends. You can of course also use control C. When there's 8 characters left, the remaining ones start to blink.
Note the box drawing characters. These are actually produced by issuing an ANSI escape code to switch to the DEC special graphics character set. In that mode, the lower case characters become line/box drawing characters. Turns out: this also works in the Terminal on the Mac!
I couldn't find a workable way to get the actual keyboard scan codes or something similar on the command line, so I can't do anything with keymaps, like the web keyboard tester does. However, turns out you can still read special keys such as the function keys and arrow keys. These produce ANSI escape codes. And again, that works in the Terminal exactly like it does on the VT420 terminal.