FacetWin Logo  
 
FacetCorp
 

FacetWin Terminal VT525 Function Keys


FacetWin allows function key programming in all of its emulation modes. This application note provides detailed information for programming function keys in VT525 mode. At the end of this application note are examples of how to embed these programming sequences in a shell script file.

The escape sequence format to use is:

DCS Ps1 ; Ps2 ; Ps3 | D…D ST

where the parameters are defined as:

DCS
The "Device Control String" is an escape character (0x1B) followed by "P" (0x50).

Ps1
The clear parameter. This has the following two values:
0 or none - clears all keys before loading new values
1 - clears just the keys that are being defined

Ps2
The lock parameter. This defines whether or not to lock the function key definitions after programming the keys. This parameter is not currently implemented in FacetWin. Here are the valid parameter values:
0 or none - locks the function key definitions
1 - leaves the function key definitions unlocked

Ps3
The modifier parameter. This designates whether the shifted, unshifted or alternate (Alt key) version of the key is programmed.
0, 2 or none - programs the shifted function key
1 - programs the unshifted function key
3 - programs the alternate unshifted function key
4 - programs the alternate shifted function key

D…D
The key definition string, made up of two parts separated by a slash character ("/", 0x2F). It looks like, Kyn / Stn, where:
Kyn is the key identifier number. (see Table 1)
Stn is the string of hexadecimal codes to be programmed (see Table 2)

A series of keys can be programmed at one time by separating the individual key definition strings by a semicolon character (";", 0x3B), like this:

Ky1 / St1 ; Ky2 / St2 ; Kyn / Stn

ST
The string terminator. This is the escape character (0x1B) followed by a single backslash character ("\", 0x5C).

Table 1 - Function Key Identifiers
Kyn
Ps3 = 1
Ps3 = 0, 2 or none
Ps3 = 3
Ps3 = 4
11
F1
Shift F1
Alt F1
Alt Shift F1
12
F2
Shift F2
Alt F2
Alt Shift F2
13
F3
Shift F3
Alt F3
Alt Shift F3
14
F4
Shift F4
Alt F4
Alt Shift F4
15
F5
Shift F5
Alt F5
Alt Shift F5
17
F6
Shift F6
Alt F6
Alt Shift F6
18
F7
Shift F7
Alt F7
Alt Shift F7
19
F8
Shift F8
Alt F8
Alt Shift F8
20
F9
Shift F9
Alt F9
Alt Shift F9
21
F10
Shift F10
Alt F10
Alt Shift F10
23
F11
Shift F11
Alt F11
Alt Shift F11
24
F12
Shift F12
Alt F12
Alt Shift F12
25
Alt F3
Alt Shift F3
--
--
26
Alt F4
Alt Shift F4
--
--
28
Alt F5
Alt Shift F5
--
--
29
Alt F6
Alt Shift F6
--
--
31
Alt F7
Alt Shift F7
--
--
32
Alt F8
Alt Shift F8
--
--
33
Alt F9
Alt Shift F9
--
--
34
Alt F10
Alt Shift F10
--
--
35
Alt F11
Alt Shift F11
--
--
36
Alt F12
Alt Shift F12
--
--

Table 2 ASCII character to Hexadecimal translations
ASCII
Hex
ASCII
Hex
ASCII
Hex
ASCII
Hex
Ctrl-@
00
SP
20
@
40
`
60
Ctrl-A
01
!
21
A
41
a
61
Ctrl-B
02
"
22
B
42
b
62
Ctrl-C
03
#
23
C
43
c
63
Ctrl-D
04
$
24
D
44
d
64
Ctrl-E
05
%
25
E
45
e
65
Ctrl-F
06
&
26
F
46
f
66
BEL
07
'
27
G
47
g
67
BS
08
(
28
H
48
h
68
TAB
09
)
29
I
49
I
69
LF
0A
*
2A
J
4A
j
6A
VT
0B
+
2B
K
4B
k
6B
FF
0C
,
2C
L
4C
l
6C
CR
0D
-
2D
M
4D
m
6D
Ctrl-N
0E
.
2E
N
4E
n
6E
Ctrl-O
0F
/
2F
O
4F
o
6F
Ctrl-P
10
0
30
P
50
p
70
Ctrl-Q
11
1
31
Q
51
q
71
Ctrl-R
12
2
32
R
52
r
72
Ctrl-S
13
3
33
S
53
s
73
Ctrl-T
14
4
34
T
54
t
74
Ctrl-U
15
5
35
U
55
u
75
Ctrl-V
16
6
36
V
56
v
76
Ctrl-W
17
7
37
W
57
w
77
Ctrl-X
18
8
38
X
58
x
78
Ctrl-Y
19
9
39
Y
59
y
79
Ctrl-Z
1A
:
3A
Z
5A
z
7A
ESC
1B
;
3B
[
5B
{
7B
Ctrl-\
1C
<
3C
\
5C
|
7C
Ctrl-]
1D
=
3D
]
5D
}
7D
Ctrl-^
1E
>
3E
^
5E
~
7E
Ctrl-_
1F
?
3F
_
5F
DEL
7F

Examples

Function keys can be programmed with a simple UNIX shell script using the "echo" command. For example, let's say we want to program the shifted F1 key to send the word "hello" followed by a carriage return.

First, translating our string, "hello" plus carriage return, to the corresponding hexadecimal codes in Table 2, we get the following:

CHAR
HEX
h
=
68
e
=
65
l
=
6C
l
=
6C
o
=
6F
\r
=
0D

After concatenating the hexadecimal codes, Stn should be:     68656C6C6F0D

Looking in Table 1, we find that the key identifier (Kyn) for "Shift F1" is 11. Remembering from above that D…D is really just Kyn / Stn, for D…D, we now have :

11/68656C6C6F0D

At the top of Table 1, we see that to program Shift Function Keys, we can set Ps3 to 0.

In most cases we want to clear only the key(s) being programmed before loading the new values, so set Ps1 to 1, and we don't want to lock the function key definitions, so set Ps2 to 1.

Our full escape sequence now looks like:

<ESC>P 1 ; 1 ; 0 | 11/68656C6C6F0D <ESC>\

Translating the escape character into octal (\033) for the "echo" command, and protecting the trailing backslash from unwanted shell interpretation, ("\" becomes "\\") we now have the one-liner shell script to program our sequence:

echo -n "\033P1;1;0|11/68656C6C6F0D\033\\"
 

Now a second, more useful example:   programming F1 - F4 to be the VT100 keys PF1 - PF4.

Looking up the keynumbers (Kyn), ASCII string sequences, and hexadecimal codes (Stn) for what we want to program, we come up with:

FKEY
Kyn
PF KEY
STRING
HEX (Stn)
F1
11
PF1
<ESC>OP
1B4F50
F2
12
PF2
<ESC>OQ
1B4F51
F3
13
PF3
<ESC>OR
1B4F52
F4
14
PF4
<ESC>OS
1B4F53

Keeping the clear (Ps1) and lock (Ps2) parameters the same as before (both set to 1), and setting Ps3 to 1 for unshifted function keys we come up with these escape sequences:

<ESC>P 1 ; 1 ; 1 | 11 / 1B4F50 <ESC>\
<ESC>P 1 ; 1 ; 1 | 12 / 1B4F51 <ESC>\
<ESC>P 1 ; 1 ; 1 | 13 / 1B4F52 <ESC>\
<ESC>P 1 ; 1 ; 1 | 14 / 1B4F53 <ESC>\

Or by stringing the series of keys together, we get one escape sequence:

<ESC>P 1 ; 1 ; 1 | 11 / 1B4F50 ; 12 / 1B4F51 ; 13 / 1B4F52 ; 14 / 1B4F53 <ESC>\

Using the "echo" command to program these sequences we would have:

echo -n "\033P1;1;1|11/1b4f50\033\\"
echo -n "\033P1;1;1|12/1b4f51\033\\"
echo -n "\033P1;1;1|13/1b4f52\033\\"
echo -n "\033P1;1;1|14/1b4f53\033\\"
or
echo -n "\033P1;1;1|11/1b4f50;12/1b4f51;13/1b4f52;14/1b4f53\033\\"

 
Now that wasn't so bad after all, was it?     ;-)

Seriously though, if you have any questions or would like assistance when programming FacetWin Terminal function keys, please contact the FacetCorp Technical Support Department.