September 25, 2023
Description
NOTE: This is a work in progress. The code's pretty stable but I may update it occasionally as needed.
The OpenSCAD code included here (genKeyboard.scad) can be used to create custom keyboards and keypads with arbitrary layouts. By default, keys are 16mm×16mm, with a 3mm spacing but you can override that on a per-key basis.
Keycap graphics can consist of any number of text or SVG items and can be arranged on the keys using the dx/dy offsets.
Each keyboard consists of 4 layers:
There are several options for the base layer:
CROSSPOINT - base uses 2 bare wires to make contact
TACTILE6MM - base uses a 6mm tactile switch
TACTILE12MM - base uses a 12mm tactile switch
DOME12MM - base uses a 12mm circular tactile dome
DOMEGX12900 - base uses a Snaptron GX12900 dome
DOME5176 - base uses a Keystone 5176 dome
Of these, I prefer the 6mm switches. They're cheap, easy to find, reliable, and have a nice tactile feedback.
Printing in PLA with a 0.2mm layer height works fine. Using PETG for the spring layer will give a bit more flexibility but isn't strictly necessary.
The crosspoint and dome bases require integrated wiring, using 12AWG solid wire to complete the electrical connections. The 6mm and 12mm switch bases are intended to be wired from underneath; any sort of hookup wire is acceptable for these. If you're feeling ambitious, you can skip printing the base altogether and mount the spring layer on a custom PCB with switches soldered onto it.
The spring layer snaps on to the base, the keys snap on to the spring layer, and the cover sits on top. To create a complete keyboard, you'll need to print an enclosure for the assembly, plus any electronics used to scan the keys. An Arduino (or compatible microcontroller) is perfectly capable of scanning the keys.
I've included 2 example files: keyboard104.scad (a 104 key keyboard) and keypad-2x3.scad (a 2×3 keypad). I've printed the 2×3 keypad and am using it as a custom character keypad for my laptop. The 104 key keyboard? No, I haven't attempted to print that. It's really just there as an extreme example of the code's capabilities.
The example code demonstrates how to generate layouts using either the genRow or genColumn functions, depending on your needs.
Caveat: The SCAD code uses recursive functions which, under certain conditions, can generate a huge number of error messages. I'd recommend turning on the “Stop on the first warning” setting in preferences, just in case.
License:
Creative Commons — Attribution — Noncommercial
10