Adding Analog Touch To (Nearly) Any Mechanical Keyboard

The new hotness for DIY electronics is mechanical keyboards, and over the past few years we’ve seen some amazing innovations. This one is something different. It adds an analog sensor to nearly any mechanical key switch, does it with a minimal number of parts, and doesn’t require any modification of the switch itself. It’s a reddit thread and imgur post, but the idea is just so good we can overlook the documentation on this one.

The key development behind this type of sensor is realizing that nearly every mechanical keyswitch (Cherry MX, Kalth, Gateron) has a spring in the bottom. A spring is just a coil of wire, and an inductor is just a coil of wire, too. By putting a spiral trace on the PCB of a mechanical keyboard underneath the keyswitch, you can sense the inductance of this spring. This does require a little bit of additional hardware, in this case an LDC1614 inductance to digital converter, but this is an I2C-readable part that can, theoretically, be integrated rather easily with any mechanical keyboard PCB and firmware.

The downside to using the LDC1614 is that sampling is somewhat time-limited, with four channels or individual keys being polled at 500 Hz. This isn’t a problem if the use-case is adding analog to your WASD keys, but it may become a problem for an entire keyboard. Additionally, the LDC1614 is a slightly expensive part, at about $2 USD in quantity 1000. A fully analog keyboard using this technique is going to be pricey.

Right now, the proof-of-concept for this analog mechanical keyswitch is just a 0.1 mm flexible PCB that is shoehorned inbetween a Cherry MX red and a (normal) mechanical keyboard PCB. The next step in the development will be a 2×4 keypad with analog sensors, and opening up the hardware and firmware examples up under a GPL license.

37 thoughts on “Adding Analog Touch To (Nearly) Any Mechanical Keyboard

  1. Great idea, but I can’t find for which usage it’s made for.
    Except telling your customers the software you sold them is not buggy, it’s them not pressing the enter key hard enough…

    1. Games seems to be the usual argument. A couple of companies have come out with designs for this to allow analog input for e.g. driving games, flight sims, or anything else. Apparently you can also use it to customise at what depth the key toggles to personalise the feel a bit.

    2. Games – harder impact if hitting the key harder, moving faster if pressing the WASD keys harder. Music – when using the keyboard as a keyboard(;P) stronger impact is directly detectable.
      In combination with a touchstick/Thinkpad nipple this could perhaps be used to support more commands without reaching for the dedicated mouse buttons. I’ve got some plans for something like that but using a method suitable for modern chicklet laptops/notebooks.

      1. i play with a joystick instead of WASD because of this. What sucks is the game devs don’t support control mixing like they should. Games like BF4 have great control config menus and games like far cry 3 lock out a controller when you use the mouse which sucks.

    3. Might be neat to make a two-layer keyboard which selects a different function for each key based on how hard it’s pressed. You could make a chording keyboard with more combinations or using less complex chords.

    4. It wouldn’t map neatly into current computer keyboard use cases; but it seems awfully reminiscent of the velocity sensitivity that is a fairly important feature in MIDI keyboards for musical use.

  2. This is an eddy current effect sensor. The shape of the metal being detected doesn’t matter – it’s the quantity of metal near the sensor which matters. As you compress the spring, it brings more metal closer to the sensor. The fact that it’s a coil has no effect.

    1. It would be interesting to discuss the method of operation of this and perhaps devise a cheaper way to sense the input.

      When you mention eddy currents, I think about the two closed loops, one at each end of the spring when the end of the spring touches the previous turn as there would be no current in the remainder of the spring that I can imagine.

      In any case the SPI chip is measuring the inductance of the excitation coil on the PCB and that inductance is being “effected” by the spring in some way.

      Surely a less expensive position to analogue circuit could be made. You could use one oscillator to drive one end of all the PCB coils/inductors and add a capacitor across or in series with the inductor to form a slope filter which when rectified would provide an analogue output which could then go though a cheaper DAC chip or micro-controller.

      The problem would be that you would need significant drive voltage if you wanted to use a cheap diode as a detector or perhaps a DC offset. Then if the drive voltage is high enough to do this then you may have RF emission problems.

      it would be great for music or even synths.

  3. Would be really nice for music makers too, inputing notes via a computer keyboard is pretty common and it’d be great to have velocity of the note. Mod/pitch/vibrato etc would be more expressive.

  4. Simple applications I can think of is:
    Music creations programs. (The keyboard of a computer typically takes the role as a keyboard for those that doesn’t have a MIDI input for their computer.)
    Typing, if one likes the idea of pressing harder for capital letters.

    Though, the sensor mentioned above would likely measure how deep one presses the key, not how hard one presses it, so for all these applications, things might get strange, since how many of us don’t push keys to the bottom? (after all, that is how most buttons are intended to work and are generally designed with that in mind and tends to “snap” from high to low… (a fix would be more mushy buttons that doesn’t snap, but the keyboard “enthusiasts” I have talked to tends to hate such keyboards.))

  5. Also, if you know which switch you’re going to use and can build a capacitive sense circuit that can handle being shorted when not sensing, you might be able to use the distance between contacts after actuation for capacitive sense.

  6. I guess that the usage for this type of keyboard is for emulators.
    For years emulators have been trying to reach perfection yet they failed to grasp the essence of the aging technology it is trying to emulate. The fun thing with old computers it that they seem to operate fine and then suddenly… the don’t.. ork… as yu epect imply ecause ome buutttttttons ar nott orking properly.
    But now there is a technology that can sense how hard you press a key, so now it is technologically possible to emulate the olde keyboard, now the machine can emulate the aging. By requiring different forces per key you can emulate the perfectly new machine, the machine at 20 years of age, the machine after 10 years in the back of a damp attic.
    Just download the failed-key-profile of your needs and the emulator can use it.

    But seriously, this is a fun approach of solving this problem. I’m sure that a real practical use for it will be found soon.
    Though if your want to do this cheaply, double the contact in the rubber membrame (make sure that one makes contact before the other). Detect the time difference between the time of contact and you know how fast the key was pressed down, meaning you know the force it was hit with. You don’t have a actual force detection on the keypress, so halve a press does not work, but at least you know how hard is was hit when the key is fully pressed. That is the way some/most musickeyboards work.

    Perhaps it could be used for upper or lower case. You want upper case, just press the key deeper.

    1. Yes, dual time contacts are the way most touch sensitive pianos work. The first closes at one third stroke the other closes at two thirds. The superior way uses a finger connected to the key that interrupts a infrared sensor pair. The output is a ramp with time that is measured to voice each note. This arrangement is available as a kit to interface to an acoustic piano. No dust or wear of contacts, only dust bunnies and spills could interfere with reliable operation.

  7. With just the slightest amount of AI you could tell several things. An identity signature of the person typing, the mood (anger level at least) of the person typing, probably something about finger strength, etc.

    1. i dont see anything wrong with dual mode functionality. analog sense does not interfere with the function of the keyswitch and vise versa. this is a lot better than other methods ive seen (like pressure pots on membrane keyboards) as it wont decrease normal typing performance or require additional pressure.

    2. It seems to me that the analogue signal is separate from the digital keypress signal.

      I.e., you’ll still the the usual keypress, but you’ll get an additional analogue measurement as well.

      I think for games this will be most useful – WASD. Some keyboards have analogue options for WASD already, but it’s pricey. The only way to get something similar to a console controller’s analogue stick behaviour for movement however, whilst retaining mouse-look glory.

      Obviously also useful for music apps for analogue keys – however when you are at that level of requirement I suspect you’d be better off buying an external MIDI/USB keyboard anyway.

      Might be good for the Stardew Valley fishing game too.

    3. The Cherry MX Red mentioned here has a linear response, i.e. no click, no tactile jump. It is mechanical in its construction nevertheless.

      AFAIK the linear switches are preferred for gaming, and tactile switches for typing, but I could be wrong. Perhaps it is just about personal preference.

    4. There are a few kinds of mechanical switches- the kind you’re thinking of, are called annoying (sorry, tacswitches- they’re also the kind I’m typing on- they are designed to electrically connect the bajillisecond you feel the click.

      There are also linear switches, which have no tactility (IE click), but on some keyboards, you can feel the point of actuation and type without going all the way down.

      Putting something on a linear switch is probably your best bet, and wouldn’t change the feel at all. (also, your speed would be more or less proportionate to your finger’s force)

  8. If a key drives a magnet into a coil that charges a capacitor that is regularly scanned by an analog to digital port the value read of it should be proportional to the velocity of the keypress, if you have a second capacitor that is loaded from a reference voltage at the same time, the key also acts as a switch you also have the time of the keypress relative to the last scan. With the speed of i/o these days you could watch the pulse from the key so even have an envelope input. Some sort of hybrid midi qwerty keyboard?

    1. Lots of tablets have touch-screens almost the size of a keyboard. I wonder if you turned up the sensitivity a bit if you could sit an unmodified keyboard on one and still get enough signal to read fractional key movement.

  9. I’m just thinking about gaming applications, and i can’t really see this working very well for an analog gaming input. I always go for a gamepad for racing games, because precise steering and breaking/accelerating are way easyer with a joystick and analog triggers. And one big advantage on a gamepad is the ergonomics are great to give you precise control without getting your hands tired quickly. If i imagine using some analog WASD keys on my keyboard (with the very limited travel a keyboard switch offers) it seems to me that it would be very hard to get any precision out of these keys, and it would be very unergonomic to control keystroke force on a keyboard like that.

    1. An additional issue for mapping to existing games is that ‘WASD’ would be four analogue inputs, but you’d really want to correlate that to two axes of movement. It might be interesting to mix keys A, and D for the horizontal and W, and S for the vertical, although I suppose that would only be effective for the horizontal axis as it’s controlled by two fingers.

  10. So it doesn’t work with keys that use rubber domes instead of metal springs? Shame.

    Actually it’s not really a shame, who ever wanted or needed a pressure-sensing keyboard? If you need analogue movement, buy one of the millions of joypads that have analogue sticks.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.