Arduino PS2 keyboard definitions

I am working on an Arduino based based CW keyer for Field Day use. I want to be able to use a PS2 keyboard for CW, RTTY, and PSK31 with my KX3 without the need for a laptop.  --So far so good.

I wanted to leverage an existing PS2 keyboard library vs. re-inventing the wheel. Get a hold of and installing the library only took a couple minutes. Here are two sites that will help walk you through the process:  

I used the K3NG files (they have more detail) and dropped them into my Library folder in my Arduino directory and I was rolling. 

As I started testing the extended keys that I would need for Field Day macros (Function keys, shifted function keys, etc) I noticed a problem. They would not show up in the serial debug display. I battled this problem off/on for about 4 hours.  My friend Google was not much help. I knew that it had something to do with the library but I was not exactly sure what or why. Eventually I worked out the problem and a solution.

I hacked together some code to display the keyboard character (if known) then the hex representation, and then the decimal representation. 

#include <PS2Keyboard.h>

const int DataPin = 7;
const int IRQpin = 2; //clock

PS2Keyboard keyboard;

void setup() {
keyboard.begin(DataPin, IRQpin);
Serial.println("Keyboard Test:");

void loop() {
if (keyboard.available()) {

// read the next key
char c =;

//print out the debug info
Serial.println ("--------------");
Serial.println ("Char, Hex, Dec");
Serial.print (c);
Serial.print (",");
Serial.print (c, HEX);
Serial.print (",");
Serial.println (c, DEC);


That piece of ugly code gave me the info that I needed. As it turned out there was no ASCI character mapped to those keys. To make this more difficult the raw Hex was a negative number so it did not match ANY of the references that I was looking at.  

Using this new found knowledge I was able to edit the PS2Keyboard.h file in my library to include definitions for the newly found values. Here is the updated library. Here is the updated test harness showing the function keys. (With the new knowledge it only took about 20 minutes to map things out and test the solution.)

While my learning curve on this issue was kind of steep I did manage to find a way to solve it that I can re-use in future projects. Now I need to get back to my real project which was to interface a PS2 keyboard into my keyer software... Field Day 2013 is coming up quickly and I am ubber short on project time.

73 de NG0R