Arduino PS2 to USB Keyboard

My April Fools joke hit a roadblock when I discovered that my coworker was using an old PS2 keyboard rather than a USB one. I had to work out a solution for that. A bit of googling turned up this on the Arduino site: PS2Keyboard. So basically I just needed to find a PS2 connector and to wire up an interrupt line and a data line and then the Arduino can read the PS2 key presses. I took the example library from PS2KeyboardExt2 since it was a bit more advanced than the PS2Keyboard library, and I modified it to map the PS2 key scancodes onto USB Keyboard HID Key Usage codes, and added a function to return a USB HID Keyboard Report.

It took a few hours to get the job done, tested with a USB to PS2 adaptor attached to my keyboard. Everything seems to be working except for NUMLOCK key changes but hopefully my coworker won't notice that.

Here's the PS2KeyboardUSB library files and the sketch:
Download file "PS2KeyboardUSB.h"
Download file "PS2KeyboardUSB.cpp"
Download file "kbd_april_fools.pde"

The project could be used to make a nice PS2 to USB keyboard adaptor.

I installed the project on my coworker's docking station Friday morning (April 1st) while he was distracted by an accomplice. We're all waiting to see if he notices it or just slowly goes mad.


Anthony Jones (unauthenticated)
Apr 5, 2011

It turns out that once the coworker noticed that the keyboard was playing up he found it quickly. He now has an Arduino sitting on his window sill at home.

Oladon (unauthenticated)
May 7, 2011

Anthony, could you post a picture or description of your wiring setup? I'm working on an Arduino + PS/2 keyboard project, and having a really hard time getting the data to /both/ the Arduino and keyboard. With the Arduino as a "tap" on the wires, neither receives the correct signals... with the Arduino acting as an intermediary, I don't know how to pass the signal along after the Arduino has seen it.

I think your project will help me, but I'm curious about how you did the interfacing.

Thanks for posting this!

May 8, 2011

Hi Oladon, Anthony was the target of the april fools prank but he did eventually return my Arduino :-). Let me know your email address and I'll send you through some details (darran [at] hunt [dot] net [dot] nz).


Pedrejo (unauthenticated)
Jul 25, 2011

Hi Darran,

Thanks so much for your work on this! I'm trying to use the PS2 -> USB code with an old CueCat barcode scanner and am not having much luck. Do you have any idea why the scanner works with the Arduino PS2 but not the HID firmware & April Fools code? Sorry, I don't really know enough to determine what the problem might be. Any ideas would be greatly appreciated.

Thanks, Pedrejo

Jul 29, 2011

Hi Pedrejo,

without seeing your code I'm not sure why it's not working for you. Does the CueCat scanner behave like a PS2 keyboard? I'd probably start with just the PS2 code and some Serial.println's to see how the CueCat was behaving, and then work on translating that to Keyboard HID output.


akshay (unauthenticated)
Mar 1, 2012

hi guys
i am trying to interface an old keyboard with aurdino uno with atmega controller having sd memory.the code given in PS2keyboard seems to be giving a lot of errors.
can suggest a suitable code and let me know if i need to extract any files into the library.i am a beginner so kindly explain in detail.

Mar 11, 2012

hi akshay, that sounds like a good question for the arduino forum. The code from my blog works fine with the PS2 keyboard I have, so there must be a problem with the hardware or perhaps with your sketch. If you post the sketch to the forum on you should quickly get some help.

Chris (unauthenticated)
Jun 13, 2012

How did you handle the PS/2 to USB conversion? Was it new firmware for the 8U2? I didn't see anything in the code that looked like USB.

Jul 9, 2012

Chris the PS/2 to USB conversion code is in kbd_april_fools.pde in this blog entry: .

SkyRanger (unauthenticated)
Sep 11, 2015

I didnt get the "April fool".
You just plugged a PS/2-Keyboard into an USB-Port with an Arduino ps/2-to-USB-Converter.

So where is the joke?
Why did u do this lot of work, just for 1st April with no joke?

If the Keyboard would open or close the calculator or a notepade, if the PC is not in use for 10 seconds or so on, then it would be a nice thing as an april fool.

Surely possible by arduino so he woild be crazy any time.

but just with an converter?

i dont see any sense for 1st april in this one.

But i honor your work its nice at all.