There has been a large push in recent times towards mechanical keyboards due to their definite, clicky feel and pronounced sound profiles. But rather than buying the latest and greatest RGB mechanical keyboard with special colored fruit switches, why not go back to the good ol’ days when every keyboard was far more tactile? Well that is exactly what Jason Ron was aiming to do with his Typewriter Keyboard project, as it lets an antique gain modern functionality while still keeping its mechanical charm.
The heart of this project is an Arduino Leonardo, and it was chosen because it have native USB support. Instead of something like an Arduino Uno which uses a secondary IC to convert USB to UART, the peripheral is directly built in. This means the device can act as a human interface device (HID) to emulate a keyboard. There is a library that comes with the Arduino toolchain called
Keyboard that exposes some of this functionality, including printing longs strings of text, writing discrete values, and most importantly, pressing individual keys. The project also uses some IR emitters and receivers, along with a momentary push button and some assorted resistors.
Typewriters are not electronic at all, so having a way to read when a key is pressed along with which one is a tough problem to solve. Damaging the machine was out of the question, so Ron came up with a way to determine the correct keys by using a couple of pairs of infrared emitters and receivers that are positioned at each side, directly across from the typebars. By wrapping the typebars for the
PL keys in black electrical tape, a bar moving in front of the IR sensor will cause its value to increase since there is more light being reflected back.
The code he wrote is also quite simple. After setting up different variables and pins, it enters into the main loop. In here, the values for the two IR sensors are read and adjusted based on previous calibration values. Then a bunch of
if statements are executed that basically see if the value lands within a certain range, and if it does, that keypress is sent to the computer with
Keyboard.press(KEY); The pushbutton allows the user to toggle the keyboard functionality on or off in case something goes wrong.
Ron wanted to play a game that reflected the time period of his new keyboard, so he chose Red Dead Redemption 2 which is based on the Western United States of the nineteenth century. As seen in his video, it seems to work surprisingly well, although there are a few drawbacks. The main downside to using a typewriter is that only one key can be pressed at a time, thus making complex maneuvers impossible.
In the future we might see some improvements made, such as a more powerful board or even TinyML that can learn which keys are being pressed on its own.