PS/2 Keyboard Interface

Jump To:
PS/2 Output Theory
           This section will take a look at the data that will actually be output from the PS/2 keyboard so that we know what to expect. You would think a keyboard is a simple device, one key press = one data output, but there's actually a lot more to these things.

Keyboard Letter Encoding (Scan Codes)



           Since computers have no clue what A, B or C are we have to encode each key into a binary number. These encoded numbers are called scan codes, and if you take a look at the two pictures above you can see that all keys on a keyboard have a scan code, and some special keys even have a dual or longer scan code. However, the main letters and numbers are all 8 bit codes.


           For a simple example of how the keyboard communicates. If the keyboard is powered through the PS/2 port, anytime a keypress is detected it will output the scancode of that key. When the key is released, it sends an 0xF0 and then the key's scan code. Even further, if the key is held down a seperate set of data is sent, but for now we won't worry about that.

Sending Data To The Keyboard
           Another function of the PS/2 protocol is that you can send data back to the keyboard to tell it to do things like turn on the capslock led, or to reset. This process uses virtually the same method to send data as we saw above for receiving data, but for simplicity sake, we will focus exclusively on receiving data from a keyboard and reserve sending data to the keyboard for a future article.



;