
Making My Own USB Keyboard from Scratch - blakesmith
http://blakesmith.me/2019/01/16/making-my-own-usb-keyboard-from-scratch.html
======
niwo
This project looks nicer than most first efforts. Some random tips for anyone
who wants to do something similar, with reservations for that it has been
awhile:

1\. Get a through hole supported usb connector instead of a pure smd one,
since the latter likes to fall off.

2\. I would avoid routing under the switches for durability, this might just
be superstition though.

3\. You can route the x and y of the matrix on different sides of the board to
make things easier.

4\. If you want to pick and place or wave solder it is probably easier to have
the smd and through hole parts on different sides of the board.

5\. No reason not to use the supported switch footprint, especially since you
can connect your ground planes with the additional holes. (well, I guess space
is a reason but still).

6\. If you are going to assemble by hand, make the pads longer as needed.
Probably especially on the microcontroller and diodes.

7\. Solder in order of cost and success rate.

8\. Always add switches, leds and connectors for debugging even if you don't
intend to use them.

9\. Some traces are quite close to the center hole, which might also be too
small? Anyway, some margin is good for reliability/yield. (especially mixing
'technologies' e.g. holes/edges and traces).

Edit: Oh, I forgot. You might consider scripting the placement of the
switches/diodes.

~~~
crshults
> 7\. Solder in order of cost and success rate.

Thanks for this. I guess I've always gotten lucky here but now I'm imagining
the frustration of getting done with all the discretes on a board just to blow
it all on the uC. Great advice, thanks again.

~~~
fireattack
Desc. or asc.?

~~~
spdebbarma
I don't know but do whatever is riskier and costlier first.

~~~
masklinn
Shouldn't it be riskier & cheaper first? That way if you fuck up you haven't
wasted your expensive components.

~~~
tapland
Components are not wasted or used up by being soldered to a board.

~~~
pjc50
They certainly can be if you're not very good at desoldering. Especially BGA
parts which require laborious re-balling for reuse.

~~~
tapland
Luckilly you won't be installing BGA parts to begin with using a soldering
iron at home.

------
agrahul
If you’re open-sourcing a project, you can get a real USB PID instead of
hijacking someone else’s: [http://pid.codes/howto/](http://pid.codes/howto/)

~~~
blakesmith
Oh nice, didn't know that! Thanks for the info!

------
neonroku
Cool project!

For folks interested in doing this themselves there are some communities out
there - others have mentioned qmk, here are some useful forums to check out:

* [https://www.reddit.com/r/MechanicalKeyboards](https://www.reddit.com/r/MechanicalKeyboards)

* [https://geekhack.org/](https://geekhack.org/)

* [https://deskthority.net](https://deskthority.net)

Depending on your level of interest/commitment you don't have to design your
PCB and software from scratch, there's a spectrum from designing your own PCB,
case, etc. to putting together components designed and sold by somebody else.

------
samstave
I have a design wish for people who make things like this: “row modules”

Basically, as an example - i wouldnt be fond of the size of that spacebar, and
would like other modules.

What if each horizontal row of the standard length on a qwerty were its own
module, and you can snap several together to make the board you want.

Want a touchpad? Snap it to the base or side. Want a touchbar oled strip: snap
it to the top. 9-key? No problem - gamer config wsad side module? Yep.

Want to just pull out the small qwerty section for some reason - just unsnap
whatever you need.

Also, from a connection perspective, they should be little round rare earth
magnet cylendars in dowl posts and you just mate the pieces this way.

Fyi, Daiso Japan carries these in packs of 8 for $1.50.

~~~
Palomides
I'm curious why you want modular parts rather than just designing a board that
has what you want? Keyboards are surprisingly easy to design now (as seen in
this article), and you can design things that would be completely unreasonable
for any modular system.

~~~
jrockway
Indeed, and this guy did it the hard way. Get a teensy, some switches, diodes,
and wire, and read this:
[https://github.com/qmk/qmk_firmware/blob/master/docs/hand_wi...](https://github.com/qmk/qmk_firmware/blob/master/docs/hand_wire.md)

There is no need to spend any time on the software side of things. It's
already been done to death.

~~~
Palomides
even if you want a custom plate, PCB, case, firmware, you can use community-
developed web tools like these to do it all:

[http://www.keyboard-layout-editor.com/#/](http://www.keyboard-layout-
editor.com/#/)

[https://kalerator.clueboard.co/](https://kalerator.clueboard.co/)

[http://builder.swillkb.com/](http://builder.swillkb.com/)

[https://config.qmk.fm/](https://config.qmk.fm/)

A neat response to this article would be someone making a keyboard using only
these tools.

~~~
mamcx
This is how I made mine:

(post is in Spanish, I wish to brag with my old mates:

[http://clubdelpra.cluster003.ovh.net/foros/showthread.php?p=...](http://clubdelpra.cluster003.ovh.net/foros/showthread.php?p=529502))

------
mncharity
Has anyone seen keyboards with non-traditional touch surfaces? Such as
trackpad keycaps?

Backstory: My fingers slide smoothly across my ThinkPad laptop keyboard, so I
was playing with optical hand tracking (with a surface mirror to better track
touch) to make the entire keyboard (and surrounding laptop) into a multitouch
surface. There were occlusion and jitter issues, even with fingernail markers,
and I set it aside while still not quite working. But I was left thinking "I
should get back to this" rather than "never again". Stroking a keycap as a
trackpad seemed nice, even already having a touchpoint. Merely touching
modifier keys (emacs) rather than having to press them. With a 3D display, I
overlaid video of the keyboard, slightly above the screen plane so it was
easily seen but only moderately annoying. And thus could overlay a multitouch
control panel that doesn't require shifting attention from the screen, or
hands from the keyboard. With screen-comparable VR/AR seemingly only a year or
three away now, with attendant changes in UI constraints, there seems an
opportunity to escape decades-old HID fetters, at least with professional UIs.

~~~
kragen
Yeah, Apple got their multitouch technology in 2005 by buying Fingerworks, the
startup that made Touchstream keyboards, which were sort of like a giant
single trackpad with key areas on it. Now that every Android phone and tablet
has this feature, you could maybe use a tablet or two as a reconfigurable
keyboard.

Myself, I really want more touch feedback from my keys, not less, but to each
her own!

~~~
secstate
I don't think OP is referring to a touch keyboard, but rather that the keycaps
of each key would be one part of a larger multi-touch surface. As your finger
left one key you could sort of "guess" the direction it was going and have
something close to one big multi-touch panel that was composed of smaller
surfaces. But I could be wrong as well.

~~~
FPGAhacker
I had this idea a while back as well. What brought it to mind was wishing I
didn't have to take my hands away from the keyboard to mouse around.

Anyway, Apple has patents covering this idea. I believe 9,041,652 is the one
I'm thinking of.

~~~
mncharity
Yes, patents have been amazingly toxic for HID progress.

Commercial HID innovation seems to be bimodal, DIY and bigco, with a patent-
induced desert in between. Take multitouch. Years of crippled small companies,
selling kits to dodge patents, to small DIY communities (DIY historically
being much less of a thing than now). Speech-to-text and Nuance. Hand pose
from webcam and colored glove research, becomes of-course-unsuccessful
startup, bought by bigco, and thereby unavailable to support further
innovation. Leap Motion's DIY Project North Star is an ongoing example -
there's software, and you can buy parts, but not devices. So while there's an
active small-company ecosystem around say keyboards, that falls off really
fast. Small-scale markets of oem support for exploration and innovation...
aren't an interesting niche for bigcos. So they produce patents and not
products, and even proven too-small-just-a-distraction-for-us markets are
abandoned.

As education innovation starts overlapping ML and tech, it looks to be picking
up similar dysfunction. Ah well.

------
mntmn
I love stuff like this. We made a whole laptop in this spirit, with a custom
USB keyboard, optical trackball, motherboard and 3d printed/cnc milled case,
also with KiCAD:
[https://mntmn.com/media/news_md/2019-01-14-status_update_on_...](https://mntmn.com/media/news_md/2019-01-14-status_update_on_reform.html)

~~~
blakesmith
Whoa, sweet project. Your assembly video is drool worthy cool. I've thought
about doing my own laptop some day, but figured I'd work my way up to that
difficulty with some other smaller projects to keep learning. Any advice to
share for doing a custom laptop?

------
userbinator
One suggestion I have is to not mount the USB connector on the board itself,
but instead on the "case" with a short pigtail leading to the board. There's a
reason the majority of PC keyboards have a captive lead which runs into a
strain relief on the case --- to keep the load off the solder joins when the
cable moves around.

Interesting thought: The microcontroller in that keyboard is more powerful
than the first IBM PC.

------
snazz
For anyone who’s tried both: are big keyboards with lots of modifiers or
little keyboards with “layers” more comfortable and functional for you? I
currently have a full-size mechanical PC keyboard and am debating buying a
Planck.

~~~
jrockway
I have an ergodox and it has too many keys. The number row is hard to reach.
The bottom extra row I basically never use. There are too many thumb keys. I
end up using the keys under v and m as raise/lower keys and putting all the
symbols (and some macros) on home row while the opposite hand's modifier is
held (so ( is that key below v held with your thumb, and j).

Having extra keys for your pointer finger sounds good (those 1.5U side keys on
the ergodox next to tgb and nhy), but it is actually difficult to precisely
decide among 3 columns that you have to absolutely position your finger to
hit. I feel like my accuracy in deciding between b or v suffers and having
another possibility doesn't help.

So my suggestion is to go small. Not having a number row may be overkill; they
are far away but I have yet to remap them. Figuring out what keys are most
important to press and making them easy is crucial. I know I hated where {},
-, =, etc. were on traditional keyboards, so I was careful to put those on
home row. It was worth it. Having an extra row of normal-sized keys instead of
control, meta, super, space... probably not worth it. The 1u keys next to the
2u thumb keys on the ergodox... I basically never use them (they're arrow keys
and page up/page down, but I navigate with emacs style keybindings so only use
them for skipping through YouTube videos and things like that; nice to have,
but impossible to use during normal typing).

Not using your pinky for enter and backspace is also great.

For completeness, my layout:
[https://github.com/jrockway/qmk_firmware/blob/master/keyboar...](https://github.com/jrockway/qmk_firmware/blob/master/keyboards/ergodox_ez/keymaps/jrockway/keymap.c)

~~~
neonroku
There are a few keyboards similar to ErgoDox but with less keys:

* [https://github.com/kata0510/Lily58](https://github.com/kata0510/Lily58)

* [https://github.com/omkbd/ErgoDash](https://github.com/omkbd/ErgoDash)

This blog shows how the Lily58 designer took the ErgoDox design and removed
the keys he found superfluous:

[https://yuchi-kbd.hatenablog.com/entry/2018/12/23/214342](https://yuchi-
kbd.hatenablog.com/entry/2018/12/23/214342)

~~~
jrockway
Yeah. I picked the Ergodox because it's basically an off-the-shelf part these
days. Order one today, you'll have it on Tuesday. The same is not true of most
other keyboards like that.

------
timonoko
I made an USB-controlled relay from old keyboard circuit board. The relay is
connected to the Scroll-lock LED, which is totally useless otherwise. Which
means I can switch the relay on from keyboard or bash-script. At the moment
the relay is connected to the ambient light in my lair.

------
keithnz
funny, I was just looking at a keyboard stream on twitch for
[https://ishtob.net/hadron/hadronv3-groupbuy](https://ishtob.net/hadron/hadronv3-groupbuy)
and I was just browsing the open source code used in the keyboard here
[https://github.com/qmk/qmk_firmware](https://github.com/qmk/qmk_firmware)

~~~
tramGG
$255 for a keyboard? Wow. What are the more higher end keyboards you've seen?

~~~
marcinzm
It's $255 and doesn't come with any switches from what I can tell. Not the
person you're responding to but I've heard good things about the UHK:
[https://ultimatehackingkeyboard.com/](https://ultimatehackingkeyboard.com/)

~~~
ComputerGuru
I didn’t like it, despite waiting a couple of years (I think) for mine to
ship.

The lack of Esc is just plain stupid and needlessly “special” for a hackers
keyboard, especially with zero space constraints. The keys themselves I’m not
a fan of, but that’s because nothing beats the buckling spring keys I’m used
to - so not counting that against them. Build quality is great, however.

~~~
neonroku
Can't you remap one of the other keys to be escape - I think for those who
care keyboard layout is highly personal - I can find somebody has designed a
keyboard that looks great and then make layout choices I find very strange.
But if the keyboard uses qmk then I can easily fix that.

If you're not happy then build your own - or buy a unicomp board and replace
the controller so you get the best of both worlds - buckling spring and
programmable keyboard.

------
kakwa_
Reminds me of the time I rewired an old Mac SE keyboard to an USB keyboard
controller.

Basically, I took an USB keyboard controller from a cheap secondhand Dell
keyboard, reversed its matrix, and then rewired every combination to the USB
controller board using a wires peeled off from an IDE connector.

Very time intensive, and to say the truth, not really working well in the end,
but, hey, I was a student at the time.

It was far less ambitious than the titled project, but here are the pictures:

[http://blog.kakwalab.ovh/IMG_6920.CR2.jpg](http://blog.kakwalab.ovh/IMG_6920.CR2.jpg)

[http://blog.kakwalab.ovh/IMG_6921.CR2.jpg](http://blog.kakwalab.ovh/IMG_6921.CR2.jpg)

(yes, it's a mess).

------
rolleiflex
Does anybody know if there’s anything inherent in this that makes it have to
be QWERTY in layout, or in shape?

What I’m thinking about is to actually make a custom physical user interface.
Less of a keyboard and more the bridge of USS Enterprise.

~~~
bonestamp2
You could make it whatever shape you want. Then program it to emit whatever
usb key codes you want (there are existing libraries to do this quite easily).

This one happens to emit standard qwerty key codes, but there are many more
that do other things. For example, there are standard key codes to launch a
browser or the calculator (and some keyboards have buttons to do that too).
You could also make it emulate any kind of standard usb HID (human interfact
device). This one is a keyboard, but you could make something that identifies
itself as a mouse, game controller, etc.

~~~
jon-wood
My Ergodox is configured so that hitting a particular key switches hjkl to
mouse control, with clicks on the other hand. I can’t say I use it often, but
it’s nice for times when you just want to click a single thing and then get
back to typing.

~~~
bonestamp2
That is great. I remember having a microsoft keyboard back in the day that had
a mouse click button and it was surprisingly useful.

------
diimdeep
[https://github.com/diimdeep/awesome-split-
keyboards](https://github.com/diimdeep/awesome-split-keyboards)

------
secure
If you’re into custom-made keyboards and keyboard parts, check out my Kinesis
advantage replacement controller project:
[https://michael.stapelberg.ch/posts/2018-04-17-kinx/](https://michael.stapelberg.ch/posts/2018-04-17-kinx/)
(only 0.2ms of input latency!)

~~~
willtim
Nice work! It would be interesting to compare the latency to the new Kinesis
Advantage 2 keyboard, which has brand new firmware.

------
subjoriented
Once I pulled a prank on a colleague by setting up a 555 timer inside their
keyboard so that alt+f4 would constantly get pressed (every ~1 second).
Because that friend was a software hacker, I knew he would look for rootkits
and all sorts of nefarious software issues that could lead to this behavior.
Anyhow, he did eventually figure it out (not after he was sure his BIOS was
infected - yes this was 2007).

What I learned during that prank was that keyboards are very complicated. A
keyboard is essentially a giant switching system where pressing keys closes
circuits, and a microprocessor looks to see what lines are high/low and infers
which keys have been pressed. There's whole systems designed around avoiding
"ghost keys", which arise because the number of combinations of possible
simultaneous button presses of the switching system far outnumber the possible
combinations of signals.

~~~
brokenmachine
If every key has a diode then you won't get ghost keys.

That's how NKRO keyboards work.

------
vfinn
This may be irrelevant, but I've long wondered, do we really need the buttons
at all. Couldn't we just have a "sensory board", where each individual could
initialize the board using their hand movement / finger press patterns to
individual letters and/or words based on probabilities.

~~~
pjc50
There have been a couple of attempts at this: projection keyboards, Magic
Leap. The technology is fine but the learning required to type on something
invisible is considerable.

------
franzwong
There is a shop in Japan for DIY keyboard

[https://japantoday.com/category/tech/japan%E2%80%99s-first-d...](https://japantoday.com/category/tech/japan%E2%80%99s-first-
do-it-yourself-keyboard-specialist-shop-opens-in-akihabara)

------
ferongr
So much effort just to type on Cherry browns. Without the stiffness of a plate
mount even.

------
petercooper
What is it like typing on a keyboard that's just a grid? Every keyboard I've
used has had each row be shifted slightly which seems to make touch typing
easier.

~~~
dkersten
I find typing on a grid much more comfortable and pleasant than typing on a
traditional staggered layout.

As an experiment, place your fingers on the home row and naturally curl them
out/up or in/down and see how straight or curved the path they follow is. For
me, on a normal keyboard, I find that the buttons above the home row are
positioned well for my fingers but for the ones below, my fingers naturally
curl over the gap between the keys, meaning I have to also bend sideways. With
a grid I can press both the keys above and the ones below without any sideways
motion (for the four keys on each hand above and below the home row testing
keys).

Nowadays I use a kinesis advantage, though, which has not only grid layout but
also has them in a curved height to more naturally let your fingers reach the
rows without any additional movements and I love it. But even on a flat
keyboard, I find a grid works better for me.

------
Solar19
Nice. This reminds me of some old patents I like for optical keyboards, e.g.
[https://patents.google.com/patent/US4379968A](https://patents.google.com/patent/US4379968A)

Though real optical would require optical equipment in the desktop's or
laptop's chassis or motherboard, and OS support, since it wouldn't be USB at
any stage.

------
vemv
The keycaps can't be easily DIYed right?

~~~
ThatPlayer
I have seen a parametric keycap library here
[https://github.com/rsheldiii/KeyV2](https://github.com/rsheldiii/KeyV2)

But standard FDM printing will not get you keycap that are smooth on the top,
as they tend to be sculpted to fit a finger better, and you're still looking
at ~0.4mm layers at best. You may be able to do it with SLA 3D printers which
are able to do higher resolutions than FDM printers.

[https://imgur.com/a/AalpV1r](https://imgur.com/a/AalpV1r) is an interesting
project that 3d printed the keycaps too

~~~
newman8r
It's hard to get the mounts on the keys just right on an FDM printer too, at
least in my experience.

------
barbecue_sauce
I'm not a mechanical keyboard guy. Is it as difficult to type on a qwerty grid
layout as it seems like it would be?

~~~
shiveringking
It takes a couple of hours of getting used to.

------
Aardwolf
Hey it looks great. Question about the circuit: is it NKRO, or is there any
shadowing or ghosting?

------
mellow-lake-day
This is some great quality content!

Great project scope, execution, and write up.

~~~
blakesmith
Thanks for the kind words. It was also a lot of fun, and full of good
learnings for future projects.

------
zacharycohn
Nice job! Did you consider 3d printing any components?

~~~
blakesmith
This project was more about learning the schematic, PCB, firmware and laser
cutting work. There might be some fun learnings from 3D printing the keycaps,
but I didn't want to expand the scope of this too much, since there were
already quite a few "risky" parts of the build (given my current electronics
skillset). The top and bottom plate design was mostly about simplicity.

------
jamisteven
Where does one find the time for such activities.

------
kevintb
Incredibly cool project!

------
artificialLimbs
Sweet. Words per minute?

------
spsrich
love the colour. Took me right back to the Data General days.

