Image couldn't load - you don't seem to have IPv6 connectivity

iljitsch.com

blog topics: BGP · IPv6 · more · my publications · my business: inet⁶ consult · contact: Twitter · LinkedIn · email

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.

Then of course it's always good to put the keycaps back where they belong. That's a task made a lot easier with a keyboard tester app such as the online one I made a while ago. However, I don't think the VT420 supports the latest Javascript features...

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.

by .


Archives: 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021