Keyboard Output Emulation

Hello Everyone,

So I am new to Arduino, but I think I have an interesting project. I have an UNO, and I would really like that to work with my project.

My project is to type on one computer (into some kind of text box), to output that data to the Uno, and have the Uno send that data on to a PS/2 port on another computer as keyboard input. So, I would physically type on one, and it would also be "typed" into another computer. I am not certain this is possible, but I am really interested in making it work; it is actually for my undergraduate thesis project.

I do think that there are pieces of this already out there, but I can't find anything that has it all put together in this way. I understand that I would need more circuitry to get from the Uno to the PS/2 port, but I am not sure what all would be required. I have also seen the Keyboard sketches, but I don't know how to make them get their input from software on my computer (PC, Windows 7, no PS/2 or serial).

Thanks in advanced for any help. I am actually expecting to hear that I am crazy for even thinking this up.

Googling "arduino ps/2" seems to give quite a few hits, there should be some ideas there for you.

I see that there are a lot of resources, but I am having trouble finding exactly what I need. I haven't been able to find Anything detailing how to get keystrokes from a computer. (It is a laptop, and the keystrokes are generated by another program, so I can't use a physical keyboard to generate the keystrokes).

I was thinking that maybe I could write an applet in Java (which I am the most comfortable with) that would be typed into, and then send those characters to the Uno, which would send the keystrokes through to the second computer (which has to see the Uno as a normal PS/2 or Usb keyboard). I don't know if this is possible though, and I have never seen anything in the Java libraries that sends data to a serial port.

I am sorry that my utter ignorance makes it hard to help me, but I would really like for this to work.

I have no idea how you could do that, sorry. Especially keystrokes that are "generated by another program". Aren't keystrokes usually generated by a human? Maybe someone else will have an idea.

It can be done, but you are going to have to learn a lot more about programming on your host system (which you didn't mention whether it was Windows, Linux, or Mac-os).

Given your original message, there might be a simplification if you only had to pass text that is sent when the user hits return. If you have to pass all of the keys, including the modifiers alt, shift, and control in their raw state, it adds to the complexity in that you have to use the more complex libraries in your OS/windows layer than simple read/write.

You would need to get additional hardware to allow the Uno to act as a keyboard. For a USB keyboard, you would get a USB host shield, such as: On the UNO, it is harder to use the USB connection as a remote keyboard, while the Leonardo/Due have builtin support. Or something different to emulate a PS/2 keyboard.

As I see it, you would break down your task into separate parts, and tackle each one separately.

  • The first part is to write a host side program that reads from the host keyboard and writes the sequence. Initially you would just write the input to the standard output. When you need to glue the parts together, you would need to open up the serial device that the OS creates when you connect your UNO.
  • The second part is to read the output of the first part. If you are just sending text, you can just do a read. If you are needing to send the modifier keys, you will need to use an encoding scheme from #1 to pass all of the information, and then decode it on the Arduino. You may have some problems if you are transmitting binary text over the serial line, as the host serial protocol may convert newlines into carriage return and newline, tabs may be expanded to 1-8 spaces, use control-s/control-q as flow control characters, or strip off the 8th bit, so you may need to encode the binary numbers to use the standard printable characters, space, and newline
  • Have the UNO act as a keyboard, and send output characters. You can initially test this without the first two steps, by sending fixed test messages.