Kbd port = natural FS interface
The keyboard port should be regarded as one of the best, early methods of interfacing your secondary flight deck controls to your sim software. After the game port or USB port, depending upon which type of primary flight controls you use, the keyboard port offers the greatest flexibility for controlling your sim's functionality.
Recreational flight sim software is designed with the keyboard in mind. If you've got a multi-mega-euro contract for a single simulator you would undoubtedly build special interface circuitry, but if you're targeting a multi-mega-customer recreational market, you aim for the most prevalent common denominator: the standard keyboard.
Getting creative with the keyboard port and recreational flight sim software means you most likely don't have to worry about writing special drivers. If you get deeply involved in home flight deck construction you will likely seriously consider some rather more complex interfacing methods. However, if you're just getting starting, it's hard to beat the combination of low cost and no required (additional) driver that use of the keyboard port offers.
Although there are a few keyboards with different connectors, the vast majority of PC keyboards make use of a six pin mini-DIN as diagrammed above. The keyboard interface is a clocked, bit serial bus using open-collector TTL voltage levels. The clock is active only when data is being sent and has a typical pulse width of 40 usec. This connection is bi-directional. Though it is predominately driven by the keyboard, the PC can send control commands to the keyboard.
The open collector nature of the bus means that keyboards can be wired in parallel. This can lead to problems as there is no means of arbitration, and transmissions from different keyboards can overlap and corrupt each other. However, in cases where you are sure only one keyboard is sending at a time, it may be a technique to keep in mind.
The keyboard port supplies five volts to the keyboard and generally has substantial additional capacity, perhaps as much as another 100ma after powering the keyboard. Caution is in order, though, as this power connection is quite likely not fused. Pulling too much current from it may damage your MOBO or power supply.
A keyboard transmission consists of a negative going start bit, eight data bits, one parity bit, and a positive stop bit. Keyboards do not send ASCII characters, rather they send scan codes which are interpreted by the keyboard driver and windows message handler. The keyboard informs the PC both when a key is pressed and when it is released. When you write code to read the keyboard input buffer you are benefiting from the windows message handler combining a shift-key down message with a letter "g" key down message when you read a "G". Generally you never see the associated key-up messages. If you would like to see everything the keyboard sends, there are windows APIs that allow that.
Build a keyboard emulator
It is certainly possible to build an interface between your flight deck's switches and a keyboard port. The data rates on the serial bus are easily managed and as it doesn't even require cracking the PC case, it's pretty easy to test. This is a good project for a programmable microcontroller. The Microcontroller Idea Book by Jan Axelson covers the 8052 microcontroller, and, though a bit dated, might be worth a peek if the do it yourself approach appeals to you. If you would rather work with Microchip's PICmicro line, you just have to get hold of a copy of Myke Predko's Programming and Customizing PICmicro Microcontrollers, 2nd edition. Predko's book has a list of keyboard scan codes, as well as, having a printed circuit board for a small PIC programmer, a hard to beat combination!
If you're planning to get into developing microcontroller projects, building a keyboard interface with one is a good project, but if that option doesn't hold much joy for you, you can buy one. Check out Hagstrom Electronics and Vetra Systems for keyboard emulators.
Use an unmodified keyboard
One of the least expensive ways to drive the keyboard port is to use a keyboard. (Well, duhhhh!) One rather direct approach is to build a panel of solenoids that is mounted just above the keyboard. Electrically actuating it causes the solenoid to press the keyboard key immediately under it. I believe this approach was initially used by Kev Saker. You might find more details about this approach in the How-To section over at FllightSim.com. Look for "Building Kev's Cockpit.
Hack a keyboard
The solenoid approach is less attractive these days as the cost of keyboards has plummeted to almost nothing. I have seen new keyboards offered for a dollar at swap meets. Even in retail outlets, it not unusual to see basic keyboards priced in the US$10~15 range. At these prices it makes sense to consider hacking a keyboard. Do this and you've got almost everything you need to interface your switches to to PC. Keyboard switches are momentary contact switches. There is nothing that says they can not be replaced by cool looking, illuminated momentary contact push buttons mounted in your flight deck. Robert Prather has written a nice article on doing just this, and posted it in the "how-to" section of FlightSim.com.
As long as the command you wish to send is a single key stroke equivalent, you don't need anything else. The challenges grow when you need to send a shift, control or alt modified key stroke. There are several solutions. A mechanical one is use two switches and arrange for one to be activated before the other. The first switch is used for the shift, control or alt while the second is the letter key.
You can also build a simple electronic delay driving a pair of relays.
Or, buy a keyboard emulator
As the number of modified keystroke commands grow, or if you need a sequence of keystrokes, you soon reach the point where it makes more sense to buy a keyboard emulator.
Keystrokes can be made even more useful through use of a free utility called key2mouse. This module can intercept keystrokes and issue Windows mouse messages. This expands the utility of the keyboard (virtual or real) by giving it the capability of controlling functionality normally controlled through mouse click. Check here for mouse2key.
Useful diagnostic software
Once upon a time, there was a Windows program that showed which key on your keyboard was pressed. I'll be darned if I can find it. It's probably on the install disk for Windows 3.11, and I'm not going there!
Fortunately, there is a freeware program by Digital Genesis Technologies that does just this. It's called KEYSCAN. This little program can help you debug your keyboard port interface device. It's better than just activating a WordPad window because it will show the state of all the keys individually along with reporting the scan codes.