This spring, as I was perusing the engineering building’s “free” pile for goodies, I found a gem – an all-in-one cash register! It had all sorts of great stuff in it: A keypad with mechanical switches, Vacuum Flourescent Displays, and even a turnkey switch. I just had to have it, so I lugged it to my evening lab session and then across campus to my car. I couldn’t take the chance of someone else nabbing it!
After ripping it into its base components, I finally had access to the part I wanted to play with – the keypad. It had plastic covers over small pieces of paper, so my imagination sparked as I realized I could replace the icons with whatever I wanted. However, I still had to figure out how to make it do something useful.
Reverse engineering
After about two hours of painful probing with a multimeter and careful documentation, I had a layout of which two wires became connected when a given button was pressed. Reverse engineering isn’t always as fun as it sounds! Now, I had a layout which I could use to code some initial tests with an Arduino clone.

The circuit layout
To determine what key was pressed at a given time, I used a double-layered Switch statement, which is essentially a lookup table. The two inputs to the lookup table are which output is currently toggled HIGH, and what input was registered at HIGH. The below animation beautifully demonstrates how this works.

Source: http://pcbheaven.com/wikipages/How_Key_Matrices_Works/
One problem is that the Arduino Pro Micro only has 16 total I/O pins (excluding serial pins), but this matrix requires 10 outputs and 8 inputs (due to the way it was wired by the manufacturer). That would be 2 more than the amount of I/O pins that we have to work with.
Thankfully, we have our friend the Shift Register (74HC595), which allows us to turn three pins (clock, latch, and data) into 8 outputs. We can even chain shift registers together, essentially allowing an infinite number of outputs for only three inputs!
In this case, we use the 8 outputs provided by the shift register + two outputs directly from the microcontroller to get our 10 required outputs. The total amount of I/O pins is then 13 (8 input, 2 direct output, 3 to control the shift register). This leaves us with 3 extra I/O pins to use for whatever we want!
# of Input pins from keypad | # of Output pins to keypad | |
---|---|---|
Microcontroller | 8 | 2 (+3 for shift register) |
Shift Register | N/A | 8 |
Technical Note: If we wanted to save even more I/O pins, we could daisy-chain a second shift register to the first, and reclaim those two direct output pins for a total of 5 free I/O pins. (We could not however do the reverse, using an 8-3 encoder IC to encode the input signals into a smaller amount of pins. More than one input pin may be High at any given time if more than one button is being pressed, which would result in the microcontroller only detecting one key being pressed. This is due to an 8-3 encoder’s priority of inputs.)
<Fancy Circuit Diagram to go here eventually>
The Code
While researching how to make this keypad work with a computer, I learned that the Arduino Pro Micro is one of the few Arduino microcontrollers that can be used to simulate keyboard presses via USB to a computer. I initially started with the Keyboard library provided by the Arduino team, then later switched to the original source (HID-Project by NicoHood), as it had had the ability to use media keys (volume controls, etc). Using my programmed lookup table, I now added functionality to the project: A single press of one of the keys could emulate a sequence of key presses, allowing shortcuts to be executed.
After some searching for useful shortcuts, I realized that one of the tedious parts of my engineering lab reports is inserting Greek letters for variables. I decided to use ALT keycodes to type special letters that are normally not found on a keyboard. I also added a few other shortcuts, specifically for using Microsoft Word (superscript/subscript, increase/decrease font size).
For more technical information on the code, check out my GitHub repository: https://github.com/fwacer/hotkeyboard
Click to show/hide code
Functional layout of keypad:
A | B | C | D | E | F | G | |
---|---|---|---|---|---|---|---|
1 | Superscript (Word) | Piezo tune | — | — | — | — | — |
2 | Subscript (Word) | Mute | Volume down | Volume up | Alpha | Beta | Change font to Symbol (Word) |
3 | Default formatting (Word) | Start/stop recording | Record last 30 seconds | — | Delta(uppercase) | Delta | Degree symbol |
4 | Increase font size (Word) | — | — | — | Gamma | Lambda | Del (partial derivative) |
5 | Decrease font size (Word) | 7 | 8 | 9 | Mu | Nu | Epsilon |
6 | Scientific format (Excel) | 4 | 5 | 6 | Pi | Rho | Omega |
7 | Currency format (Excel) | 1 | 2 | 3 | Theta | Phi | Sigma (uppercase) |
8 | Add borders to cell (Excel) | 0 | 00 | . | Sigma | Tau | — |
Visual layout of keypad icons:
Most of the icons were made by me, but a few were made by others. Expand the tab to see attributions to the authors.
Click to show/hide icon source links
Magic hat and circular arrow icons were made by https://www.freepik.com/ from www.flaticon.com
Magic hat source: https://www.flaticon.com/free-icon/hat-and-magic-wand_68284
Circular arrow source: https://www.flaticon.com/free-icon/refresh-left-arrow_61838
Music icon was made by https://www.flaticon.com/authors/bogdan-rosu from www.flaticon.com
Music note source: https://www.flaticon.com/free-icon/quaver-outline_69447
Half Life (video game) lambda icon made by https://half-life.fandom.com/wiki/User:Klow
Half Life logo source: https://half-life.fandom.com/wiki/File:Lambda_logo.svg
Everything else was made by me, and is hereby released under Creative Commons Attribution 4.0 International License.
Cleaning it up
The keypad was pretty dirty from the years of being used as a cash register. I took off all of the key caps and their covers, and washed each one individually, as well as the base chassis. This process felt like polishing a diamond that was found in the rough.
The Enclosure
Making the box was a new experience for me, and I wanted to make sure that it looked good, so I put a lot of time and effort into making sure it enhanced the overall project.
I chose to make it out of 1/8″ MDF, since it is easily workable with both powered tools and hand tools. For the face plate that fits around the keys, I initially used a router to make slots, but due to my measurements being off, the slots were angled slightly. I chose to do the rest of the slots with a drill press get rid of larger amounts of material, and then used a chisel to carve out square holes. After some sandpaper, the face plate fit nicely between the keys.
Initially, the face plate sat a bit low on the keys, so I simply added some spacers to make the keys sit a bit more flush. After, I glued edge pieces together to make the sides of the box, with the help of a ratcheting strap and some plastic corner helpers. I had to make sure not to tighten it too much, or the wood would start to bow.
I then drilled holes for the speaker volume potentiometer and the micro USB cable, which I should have done before I glued the box together.
After gluing the bottom piece to the sides, some more sanding and filing to make the bottom, sides, and top fit nicely together, I drilled a series of holes for mounting the keypad chassis to the bottom of the box. I also drilled concentric holes from the top through the bottom in each of the four corners for screws to hold the lid on.
I used countersunk brass finishing screws that connected to countersunk nuts on the bottom side of the bottom. This was tricky to do with only 1/8″ material! Due to the length of screw I selected, the machine screw and nut were just barely able to mate.
Finally, it was painting time. After testing on some cutoffs of MDF, I realized that the black satin spray paint I had turned out very blotchy, after drying. This could be partly due to the linseed oil stains that you can see on the front. I determined that I needed to use a sealer before painting, so I picked up some shellac & primer spray paint.
( Note: I did have to scrape the paint out of my countersunk holes in order to make sure the screws and nuts would be able to reach each other! )
After that, I painted it with my black spray paint, and then finished it off with a clear sealer to give it resistance to scratching. After glueing a layer of black carpet/foam craft material to the bottom, I call this project complete!.

This was really fun and I learned a lot about what it takes to not just make a product that works, but that looks good too. See below for more pictures of the finished product. I hope you enjoyed learning about my building experience!
Update 2019-08-11: This project has been featured on Hackaday and Hackster! Thank you Kristina and Jeremy for your nice writeups. 🙂
https://hackaday.com/2019/08/08/cash-register-hotkey-board-is-on-the-money/
https://blog.hackster.io/cash-register-transformed-into-custom-shortcut-keypad-7c0ddee50bdb
See below for a summary album of the build.
Preview of the final product on my desk. The original cash register. I got this from the “Free” pile in the engineering building. Our student society had long since moved to a smartphone-based payment solution for tshirts, so they no longer had use for this. The cash register, torn apart. Lots of good components in here! The score: the keypad, two VFDs, a turnkey switch, a solenoid. Some of my initial testing on breadboard. I used the lookup table with simple print statements to verify that the correct key was being pressed. The keypad was pretty dirty, even after giving it a spraydown with compressed air. Time for a deeper cleaning. Washing all the individual key caps and covers. I used a combination of a cloth and some Q-tips to get in the hard to reach places. The key caps and covers drying after being meticulously hand-washed with a cloth and Q-tips. The baseplate, all clean! All cleaned up! I also printed some new paper slips to put under the keys. The first draft of paper slips. I ended up scrapping everything but the greek letters for key functions with more utility. The first draft of new key cap legends (paper slips). I ended up scrapping everything but the greek letters for key functions with more utility. My wiring diagram before I (gasp) take it all apart, then solder it together! Black wires that were from the cash register manufacturer are desoldered, and new wires are cut. I wanted the microcontroller to sit at the back so it’d be out of the way. The outputs (blue) and inputs (yellow) were fed through a gap that ran through the centre between the keys. I used two straws to make the process easier. After feeding them, I used a multimeter to find the two ends of each wire and soldered them to their connections. The outputs (blue) and inputs (yellow) were fed through a gap that ran through the centre between the keys. I used two straws to make the process easier. After feeding them, I used a multimeter to find the two ends of each wire and soldered them to their connections. A speaker with a volume potentiometer have been soldered on now, and the keycap paper slips have been finalized. I can always change them later if needed. Face plate cut from MDF finally fits over the keys! Glueing in spacers to make the face plate sit higher on the keys. This will also help reduce the dust that will get inside the enclosure. Glueing up the sides of the box. My uncle had these very nice corner helpers which I used with a strap. The box is looking good! Needs some final sanding and then it’s painting time! The box is looking good! Needs some final sanding and then it’s painting time! A final look in the interior before it’s closed. Finished box! I added countersunk brass finishing screws, with countersunk nuts on the bottom.. Painting. I used black satin spray paint over a shellac primer and sealer. It gave a much better finish than without the sealer. Without the sealer, my test piece came out blotchy. Final product! Final product! Final product! Final product! Final product! Final product! Final product on my desk. On the bottom I glued a thin foam material that my uncle had laying around from a craft store. Final product on my desk.
3 thoughts on “Custom Hotkey Keypad Project”