Button Action Codes
On the Button Setup screen, you specify the action a button should take. This table shows some common action codes. Skip to Discussion.
Code |
Description |
|---|---|
\xFFE1 |
Shift |
\xFFE3 |
Control |
\xFFE7 |
Option |
\xFFE9 |
Command (Alt) |
\xFF08 |
Backspace |
\xFF1B |
Escape |
\xFF51 |
Left Arrow |
\xFF52 |
Up Arrow |
\xFF53 |
Right Arrow |
\xFF54 |
Down Arrow |
\xFF55 |
Page Up |
\xFF56 |
Page Down |
\xFF57 |
End |
\xFF50 |
Home |
\xFFFF |
Delete |
\xFFB0 |
Keypad 0 |
... |
|
\xFFB9 |
Keypad 9 |
\xFF9F |
Keypad Clear |
\xFFBD |
Keypad = |
\xFFAA |
Keypad * |
\xFFAB |
Keypad + |
\xFFAC |
Keypad , |
\xFFAD |
Keypad - |
\xFFAE |
Keypad / |
\xFFBE |
F1 |
... |
|
\xFFE0 |
F35 |
Discussion
On the Button Setup screen, the "Action" field is where you enter these codes. Generally, a code causes a keystroke to be sent to the remote computer. Therefore, you can cause buttons to control the computer in any way a keyboard can.
Putting plain text in the action field simply causes that text to be sent. For example, entering "hello" in the Action field (without the quotes) will cause the five characters "h", "e", "l", "l", and "o" to be sent to the remote computer when the button is touched. However, most of the time, we want a button to send a single keystroke like "Left Arrow" or "Command-F" or some such thing, to invoke an application menu command. For those actions we use special text sequences that start with a backslash.
The backslash "\" is a special character when it appears in the action string. It causes one or more subsequent characters in the string to be interpreted differently.
"\n" will send a single newline character.
"\t" will send a tab.
"\r" will send a return.
"\\" will send a single backslash.
So for example, "hello\rthere" will send "hello" followed by the return key, followed by "there".
"\p" is special. It must be followed by exactly two decimal digits from 01 to 99 that represent a number of seconds to pause. Thus, "ABC\p05XYZ" means to type "ABC", then pause five seconds, then type" XYZ".
"\x" is extra special. It must be followed by exactly four hexadecimal digits that represent a key code. Key codes are numeric values that represent special keys like the Escape key, arrow keys, and so on.
For example, the hexadecimal code for the Left Arrow key is FF51, so the action code "\xFF51" would cause the Left Arrow key to be sent to the remote computer. Hex digits can be upper or lower case. The hexadecimal key codes are as defined in the X11 and RFB protocols, and there are hundreds of them. Most of them represent normal keyboard keys and various Unicode characters.
You can just enter plain text in the Action field, so for regular text you don't need key codes, but codes for the special keys, such as the arrow keys, are quite useful. Some useful codes are listed below. The results of poorly formatted escape sequences, such as where a backslash is not followed by one of the specific letters shown above, or \x is not followed by exactly four hex digits, is undefined.
Every key that is sent is immediately pressed and released. In other words, the keys are "tapped" and not "held". However, a very few \x keycodes are exceptions to this rule and are treated as "toggle" codes. These codes are the exceptions:
"\xFFE1" Shift key (left side)
"\xFFE3" Control key (left side)
"\xFFE7" Meta key (left side) (interpreted as the Option key on a Mac)
"\xFFE9" Alt key (left side) (interpreted the Command key on a Mac)
The first time one of these codes are encountered in the action string, a keycode is sent to press the key and keep it held down. Therefore subsequent keys are shifted appropriately. To release the key, place its \x keycode into the string again. The second time the code is encountered, the keycode is sent to release the key. Subsequent encounters of the same code continue to toggle the key state. Note that the key state is tracked, and if any of these special keys are still pressed at the end of the action string, key codes are automatically sent to release the keys.
So for example to send Command-Q to a Macintosh remote computer, you can use the action string "\xFFE9Q". To send Control-Alt-DEL to a PC, you could use the action string "\xFFE3\xFFE9\XFFFF".
Only the codes listed above are treated specially. There are alternate "right side of the keyboard" codes for Shift, Control, Alt and Meta and those are not treated as exceptions, and are "tapped" as with other normal keys.
Note also that the Shift is an unusual case. To send upper and lower case alphabetic characters, just type them into the action string as upper or lower case and it will be fine - you do not need to use the Shift code. The Shift key code should only be used to get special non-alpha codes, such as Shift-Escape for example.