Important Note: Although personally I hate to use keys as interface method, and I'm glad it is not necessary for the Level-D 767, for other add-ons this is often the only option.
There are two possible ways to send keys from within a SIOC script.
Method 1: SIOC as a keyboard emulator.
You send a value to a variable with Link KEYS:
Var 1 Link IOCARD_SW Input 116 Type I
{
IF v1 = 1
{
&Key = 37
}
ELSE
{
&Key = 0
}
}
Var 2 name Key Link KEYS
Note that you always have to reset the Key variable to a value that has no key attached (in this example 0) otherwise SIOC will not detect a second assignment of value 37 to &Key (because the value does not change, nothing will happen).
In the sioc.ini you define what key will be sent if this Keys variable receives a certain value:
[************** KEYBOARD EMULATOR MODULE ***************]
window = "Microsoft Flight Simulator X"
#37=B
This method works ok but it is rather basic in the ways that keys can be defined.
An advantage is that you can specify the window the keys will be send to, so you can use this to send keys to any program window (although only one, and it must have focus). A drawback is that you can only use this method with Flight Simulator and SIOC running at the same PC.
Method 2: SIOC toggling FSUIPC virtual buttons
There is an easier, more user friendly and and more powerful way of generating keys from within SIOC, it is based on the facilities that FSUIPC provides.
FSUIPC contains the concept of a virtual joystick with 32 buttons. Nine of of these joysticks, each DWORD long (4 bytes), are available starting from FSUIPC offset 0x3340 (see FSUIPC for Programmers.doc in the FSUIPC SDK):
"Each DWORD represents one joystick with 32 buttons. If an external program sets or clears a bit in any of these 9 DWORDS the "Buttons" page in FSUIPC will register the change of a button operation in one of Joystick numbers 64 to 73 (corresponding to the 9 DWORDS). So, FSUIPC can be used to program whatever action the user wants."
In the next small part of SIOC code we let SIOC toggle bit 0 of FSUIPC Joystick 64 upon a press of a momentary push button connected to input 116:
Var 1 Link IOCARD_SW Input 116 Type I
{
&FO_JoyStick64 = CHANGEBIT 0 v1 // toggle bit 0 of joystick 64
}
Var 2 name FO_JoyStick64 Link FSUIPC_OUT Offset $3340 Length 4
Simple is not it? We could do exactly the same for the other 31 buttons of Joystick 64 or for each button in the other 8 Joysticks.
Assuming SIOC is running this SIOC code, we start Flight Simulator, open the FSUIPC module and we select the "Buttons+Switches" tab. If we now push our button the following information will appear:

We see the Joystick number 64 and button 0 is recognised!
Now we 'tick' Select for key press, click Set, and type in the key(-s) (at our keyboard) that we want to have sent by FSUIPC if this virtual button is pressed (again).
Contrary to Method 1, FSUIPC always sends the keys to the current active window at the Flightsim PC. Note that this also works over a network, via wideFS.
Note that FSUIPC is very powerful, we can do much more like specifying sending the key repeatedly when the button press is held, or to generate another key if the button is released. We can also do other things than sending keys, like selecting a FS control or one of the PM controls.
Note also that it does not matter where your SIOC program runs, the virtual buttons will always be recognized by FSUIPC at your Flightsim PC.