KeyMouSerial Solves Your Raspberry Pi Keyboard Problems

All laptops have a working keyboard and mouse built into them, the only problem is that you can’t use these tools on other computers that don’t have them. At least, until now. [Peter] has created the KeyMouSerial in order to use his laptop’s keyboard and mouse as physical devices on his Raspberry Pi, finally freeing the bonds holding our laptops’ human interface devices back.

The software for KeyMouSerial copies keystroke and mouse information and sends this out via a serial port on his laptop (using a USB to serial adapter). From there the information is translated by an Arduino into HID commands which are sent via USB to the target computer, in this case a Raspberry Pi. It’s a pretty elegant solution to carrying a bulky keyboard and mouse along just for a Raspberry Pi, or for any computer that might not have access to a network and SSH.

[Peter] has also been working on using his iPod as a serial-to-USB converter, so if you’re a Rockbox developer and want to help out then drop him a line. All of the software is available (for Windows, Mac, or Linux) including the Arduino sketch if you want to try this software out for yourself. And, if you don’t want to turn a computer into a keyboard and want to go the other direction and turn a keyboard into a computer, that is also an option.

36 thoughts on “KeyMouSerial Solves Your Raspberry Pi Keyboard Problems

        1. The serial console isn’t helpful if you need to use the mouse. Networks are particularly troublesome when my laptop doesn’t even have Ethernet, and my Raspberry Pi doesn’t have WiFi. I already own an Arduino, so price isn’t an issue.

      1. You mean running V-USB on something with USB hardware, like a 32U4, to get two USB ports (one hardware and one bit-banged)? I’ve never looked into it before, but I’d love to hear if that’s supported and how well it works.

        1. > Why would you need to have 2 USB devices?

          One USB to the hose, one USB to the client.

          The setup connects to one machine via USB-CDC, transfers data via UART to another device which connects to a second machine via USB-HID and sends that data as mouse/keyboard events.

          If you wanted to do this “without the USB-serial-USB conversion”, i.e. with one device/one chip, I’m not sure how you could do it without two physical USB plugs. Hence my wondering if the suggestion of V-USB can support two USB ports, possibly with hardware handling one of the ports.

          I suppose you could have two MCUs running V-USB, but you’d still be doing “USB-serial-USB” (or USB-I2C-USB, etc), just on a single PCB. But running both USB ports off a single MCU would be pretty cool.

          Plus, if V-USB can be used to support two USB ports on the 32u4, it would be interesting in general. It would allow a variety of low-cost facedancer clones, if nothing else.

        2. V-USB is device only. 32U4 is device only. Even if you extend V-USB to handle host side of the communication (which it does’t support atm), can you write a USB host stack in 32kB of FLASH and 2.5kB of RAM? I supposed you could kludge it with a MAXIM SPI-USB bridge chip, but that is much more expensive that a native solution.

          Time to get you head out of the 8-bit world. There are chips with 2 USB ports: OTG capable and device USB port.

      1. Other way around: KeyMouSerial goes from my laptop to USB into a target computer (e.g. Raspberry Pi).
        Although I have written a Linux version in case you want to use your RPi as a hardware key logger, sitting between the USB keyboard and another device.

        1. $10 for a prototype part, one that would be reused for other prototypes, doesn’t seem all that too expensive really.

          For a final product sure, that is very high, but as we are speaking of the Raspberry Pi I can only assume we aren’t talking about final products here.

      1. Do you mean to replace the USB-serial on the host or to replace the Arduino on the pi (or one for each, I guess)? I assume you don’t mean to serve both USB ports at the same time?

  1. Keep throwing your money in a slow, incompatible hole? I feel like the Raspi “Foundation” (sounds so much better than money grubbing corp) should send everyone a capsense Xmas card with a full qwerty and trackpad section in the card to make up for selling the world effectively “one shoe”.

  2. But if you need a mouse and keyboard, you need a display, which this doesn’t help with. And if you’re hauling a monitor around, one of those tiny combination keyboard+trackpads doesn’t add much to the load, does it?

    As far as the “how I would do this differently”, it seems like every wireless mouse/keyboard in the world comes with a “2.4GHz nano dongle”, which is almost always based around a nrf24 radio connected to some sort of USB controller that translates to HID. Seems like plugging that arduino (or anything with minimal USB) into the host computer and adding a nrf24 should let it talk to a stock nrf24 dongle in the raspberry. Or, if you want to hack the dongle, Logitech seem to be pretty good about always using flash versions of MCUs (not OTP), and breaking out programming lines to testpads. They even built their nano receiver with an ATMega16U2+NRF24L01 for a while, if you want to stick with the AVR ecosystem. Plus, with it being wireless, you can always look at the FCC internal photos before buying a particular dongle to know exactly what you’re getting and how hackable it will be.

    Seems like a USB bluetooth receiver would also work quite well, though you couldn’t pair with it and use it until after the OS has loaded on the Pi. But I assume utilities for sharing your mouse and keyboard over bluetooth are available for nearly every host device imaginable; Windows even comes with one built-in.

    1. I think the point here is to avoid wireless/BT and UTP, and to use the notebook keyboard.
      So no BT keyboard, and no other keyboards regardless of their dongles.

      Here are limitations mentioned on the link:
      a. I can’t install software on the target computer.
      There is some equipment in the factory downstairs that we want to monitor, but changing the system in any way will void the manufacturer’s warranty. Instead of buying a hardware USB keylogger, I decided to build one using an Arduino and Raspberry Pi.
      b. The host and target computers are on different networks.
      The network connection in the office is rather bad, but usually problems only happen on WiFi or Ethernet alone, not both at the same time. So I keep my personal laptop connected to the Ethernet network, and the company laptop connected to WiFi. I could use an external keyboard and KM switch, but I like my laptop’s built-in keyboard more, and I need the desk space.

      The exercise is to somehow get the laptop keyboard data to things like the raspi and other computers with the above stated limitations as you can see.

    2. A display could be USB TV tuner, or pico projector, or a TV in a hotel room, or projector in the conference room where you run your demos.
      A laptop-Arduino-2.4GHz-USB solution sounds more complicated than this, but you’re welcome to reuse the key logging code for your project if you need!

  3. I wonder if those laptop keyboards don’t internally use the same chip as USB keyboards, because then you might be able to simply hack in a USB cable.
    Although it is a bit hard to install things in the tight quarters of laptops I suppose.

    1. They are usually just a membrane keyboard with conductive ink. The actual keyboard decoding is done on a microcontroller on the motherboard. Same for bluetooth keyboard, old thinkpad, IR keyboard etc. The microcontroller might be hanging off PS/2 out of chipset.

  4. The Rube Goldberg machine way of solving this problem is a fine example of why software are so bloated today. People are using prepackage solutions and pile on frameworks than to come up with more direct solutions.

  5. I’m not sure if I’m getting exactly what he is trying to do? Like a remote desktop? I’d be sorta surprised if there isn’t one out there that you could get running on the Pi. That said back when I was still using a Pi after I got it initially setup and killed the GUI, I just SSH’d into it from there on out.

    1. Not remote desktop, just copying the internal keyboard inputs to a USB male output device. You were able to SSH because you had a network available, but that luxury isn’t always there when travelling. You also needed to enable SSH during your initial setup – if your SD card had become corrupt, you’d have been stuck.

      1. As long as your laptop has built in Wifi and you have a wifi dongle for your SBC (assuming it doesn’t have built in) you can always Ad Hoc. If the image becomes corrupted odds are you are going to end up needing to reflash it. If I was going to be traveling I would like to think (tho I couldn’t make any guarantees) that I would have the foresight to clone an image that was already setup how I needed it to be setup.

        That said I can see how something like this would be useful, it hadn’t even initially hit me that this is effectively the same as the built in serial interface for the C1. Which I did use for the initial setup and it was nice to not have to bother with hooking up the screen or a keyboard to the thing.

  6. On Linux at least you can set up a hotspot. If not then one could use a mobile phone to do that. Would that not provide the networking needed to do the SSH?

    Having said that, I appreciate your having put a lot of work into finding a solution to a problem and then sharing that work. Identifying an application where this solution works is the issue you were trying to address with this article. Great work.

Leave a Reply to Peter BurkimsherCancel 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.