Jump to content

Hacking a USB Keyboard, How Hard Is It?


Ty Tan Tu

Recommended Posts

I am just thinking out loud. I have been thinking about building a custom KSP controller, but when I start looking at the components and programming required, I started to get a bit overwhelmed. But then I started thinking... A USB keyboard already has all the circuitry and programming built in. 

As I understand it, the typical keyboard has a circuit board and two sheets. The outer sheet connects with the physical key. The top sheet then contacts a point on the second sheet. The second inter sheet contacts a point on the circuit board. So if you could map the first sheet to the second sheet you should know which pins on the circuit board produces specific codes.

I should take a keyboard apart and see just how small the board is (I am not very good at soldering), but would it be possible to hack a USB keyboard as the starting point for a custom KSP controller?

Link to comment
Share on other sites

Taking apart stuff is fun :D

 

You can replace the coated plastic sheets with actual wiring and proper heavy-duty-switches, the two sheets are more or less the X and Y axis of a switching matrix, rows and lines, so to say, but not exactly.

Some have direct matrices, some have resistor networks with fewer wires, analog voltage discrimination, so to say.

But I can't tell you which keyboard utilizes which switching type, didn't rip open any keyboards for years now^^

 

You can as well buy a barebone-USB-keyboard-driver, a printed circuit board for experimentations, electronic stores for hobbyists usually have such stuff and they are only a few bucks.

Don't bother with the plastic sheets (cutting/soldering/rewiring), lots of tears are sure to come, they only exist for cheap mass production^^

 

Youtube has quite a lot of resources, if you want to master soldering, it's actually pretty simple, you just need steady hands, and of course the tools themselves. And of course a little bit of self discipline and physical awareness, resting a hot soldering iron on ones lap is not very recommendable (I have seen people doing this).

All detailed information about which solder to use, which flux enhancer, which pre/post cleaning agent and the specific teperatures is available online.

 

And if you should destroy one keyboard, don't mind, remove all internal stuff and plant some garden cress inside the keyboard and let it grow between the keys, looks nice :)

Link to comment
Share on other sites

I've tried this and been frustrated with the poor construction of any keyboard cheap enough to be okay taking apart!  I got frustrated trying to physically attach to the circuit board...  but that was ages ago and I don't remember what EXACTLY was annoying me.   Though, yes, you'll have to tag on to the X and Y lines and trigger both of those to send the keystroke.    

You REALLY won't regret getting into something like Arduino - there's a simple library to enable arduinos with the right usb chip to emulate a keyboard very simply - https://www.arduino.cc/en/Reference/MouseKeyboard .  There's a huge community around arduino, lots of tutorials, and a couple of KSP implementations already that are doing basically what you want to do that might be worth looking into, and would definitely be places to ask for help.

I'm ALSO playing myself with a raspberry pi idea... that utilizes the KRPC plugin to move data over network.  The idea would be to roll a raspberry pi image that anyone could just burn to an SD card and run with - so when you booted up you got a bunch of telemetry data on the HDMI screen..and that is almost done... and when finished I was going to experiment with a simple way to allow people to attach buttons to the GPIO pins?   Maybe add a .cfg file people could edit to route the button pins to whatever functions they wanted control of?  But that's more advanced than you want to get into right now!  

Let us know what you end up trying and how it works out!

 

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...