from Hacker News

Making My Own USB Keyboard from Scratch

by blakesmith on 2/16/19, 10:57 PM with 129 comments

  • by niwo on 2/17/19, 12:50 AM

    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.

  • by agrahul on 2/16/19, 11:55 PM

    If you’re open-sourcing a project, you can get a real USB PID instead of hijacking someone else’s: http://pid.codes/howto/
  • by neonroku on 2/17/19, 2:11 AM

    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://geekhack.org/

    * 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.

  • by samstave on 2/17/19, 12:07 AM

    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.

  • by mncharity on 2/17/19, 2:59 AM

    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.

  • by mntmn on 2/17/19, 1:51 AM

    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_...
  • by userbinator on 2/17/19, 3:07 AM

    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.

  • by snazz on 2/17/19, 12:16 AM

    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.
  • by timonoko on 2/17/19, 6:02 AM

    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.
  • by keithnz on 2/16/19, 11:35 PM

    funny, I was just looking at a keyboard stream on twitch for 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
  • by kakwa_ on 2/17/19, 10:33 PM

    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_6921.CR2.jpg

    (yes, it's a mess).

  • by rolleiflex on 2/17/19, 1:37 AM

    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.

  • by diimdeep on 2/17/19, 7:31 PM

  • by secure on 2/17/19, 2:35 PM

    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/ (only 0.2ms of input latency!)
  • by subjoriented on 2/17/19, 6:18 PM

    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.

  • by vfinn on 2/17/19, 1:13 PM

    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.
  • by franzwong on 2/17/19, 9:17 AM

  • by ferongr on 2/17/19, 12:04 PM

    So much effort just to type on Cherry browns. Without the stiffness of a plate mount even.
  • by petercooper on 2/17/19, 11:23 AM

    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.
  • by Solar19 on 2/17/19, 2:17 AM

    Nice. This reminds me of some old patents I like for optical keyboards, e.g. 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.

  • by vemv on 2/17/19, 12:02 AM

    The keycaps can't be easily DIYed right?
  • by barbecue_sauce on 2/17/19, 1:36 AM

    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?
  • by Aardwolf on 2/17/19, 2:48 PM

    Hey it looks great. Question about the circuit: is it NKRO, or is there any shadowing or ghosting?
  • by mellow-lake-day on 2/17/19, 5:14 AM

    This is some great quality content!

    Great project scope, execution, and write up.

  • by zacharycohn on 2/17/19, 4:01 AM

    Nice job! Did you consider 3d printing any components?
  • by jamisteven on 2/17/19, 8:36 AM

    Where does one find the time for such activities.
  • by kevintb on 2/17/19, 11:51 PM

    Incredibly cool project!
  • by artificialLimbs on 2/17/19, 5:21 AM

    Sweet. Words per minute?
  • by spsrich on 2/17/19, 5:48 PM

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