PS/2 Keyboard IR Receiver

Project overview

A few years ago, someone gave me a small wireless infra-red keyboard, part no. RC-KB2, designed
to be used with a Kenwood audio system. As soon as I saw it, I wanted to discover it's transmission
format. Why? Because I would then be able to build a small receiver which would allow me
to use this keyboard on a PC with a PS/2 port.

Two years later, I finally found (or took?) the time to do it. This page's purpose is to
document the project. Maybe someone else would like to use a keboard like this one with their PC?
In any case, the receiving part of the code could be rewritten for other keyboards or even
regular infra-red remotes.

Technical Details

When the keyboard emits infra-red, it is not continuously. In fact, it modulates the infra-reds
at a frequency between 35 and 38 Khz. I did not measure the exact frequency, but I assume it is in the
35-38 khz range because an infra-red receiver salvaged from a VHS Vcr receives the signal correctly at
a pretty good distance.

After looking at the receiver's output with a digital oscilloscope, I understood how
the data was transmitted. As my infra-red receiver had an active low output, a low level in the
following diagrams indicates that an infrared wave was present.

When the keyboard is sending a key press event, it starts
by generating the following signal which I called 'Attention':

4.5ms
----+ +----
|________|
9.1ms

Right after the attention signal, the keyboard sends the data bits. The time elapsed
between active pulses (560us) varies depending on the bit value being transmitted (1 or 0). A long time
(approx. 1640us) represents a 1 and a short time (approx. 560us) represents a 0.

-----+ +-+ +-----+ +-----+ +-+ +--...
|_| |_| |_| |_| |_|
0 1 1 0 ...

When a key is held down, the keyboard sends a short signal which I called 'repeat':

2.2ms
----+ +--+ +----
|_________| |_|
9.1ms ^
600us

The keyboard sends 32 data bits, in other words, 4 bytes. Here is the meaning of each byte:

Byte

Description

First

Peripheral Identification. Constant value.

Second

Keycode high byte.

Third

Keycode low byte.

Fourth

Bitwise NOT of the keycode low byte. Adding the third and fourth bytes
will always result in 255. Useful for error detection.

I compiled a list of the codes emitted by most keys on the keyboard. The [shift] keys cannot be
paired with all keys. The [Room B] keys act as a kind of [shift] keys but they cannot be paired with
the same keys. Unlabeled keys on the keyboard do not generate events.keycodes_rc-kb2.txt

Keymap

The keyboard

This keyboard was designed for a specific purpose. Therefore, it is quite different from
a regular PC keyboard. Many keys are missing: ctrl, alt, F1-F12, Home,
End, Page up, Page down, Insert, Delete...
Also, this keyboard has keys which are not normally present on a PC keyboard:
Disc Sel, Sub out monit., User file name, Room B...

The biggest usability problem I faced with this keyboard is the fact that there are only a limited
number of possible key combinations. And when a combination works, for instance shift + a,
a different keycode is sent. This is very different from a PC keyboard which would transmit the
following sequence instead: 'Shift key pressed, A key pressed'...

Here is an overview of the possible key combinations. See
keycodes_rc-kb2.txt for the full list:

Shift keys may be combined with all letters keys, numbers keys and the following character keys: ;',./-+

With such limitations, how can we do a CTRL +C or an ALT + F4? What about SHIFT + Page-up? Simply impossible. In
order to work around this, here is what I did:

After the CONT PLAY key has been pressed, the next key I send to the PC is
preceeded by the CTRL pressed event and followed by a CTRL released event.

After the Sub Out Monit. key has been pressed, the next key I send to the PC is
preceeded by the ALT pressed event and followed by a ALT released event.

It is possible to press CONT PLAY followed by Sub Out Monit. to obtain a CTRL + ALT + somekey event.

Here is a table which describes which keyboard keys generate which standard PC keyboard key events. Obvious
keys, such as numbers, letters and ponctuation are omitted from this table. Of course, some
keys are missing. But I dont plan to use this keyboard for programming or playing games so it
should be fine. Anyway, if I ever need other keys, I'll be able to implement them.

Disclaimer

I cannot be held responsible for any damages that could occur to you
or your equipment while following the procedures present on this page.
Also, I GIVE ABSOLUTELY NO WARRANTY on the correctness and usability
of the informations on this page. Please note, however, that the procedures
above have worked in my case without any damages or problems.