	KEYCODE.EXE for Tera Term
	T. Teranishi
	
	Copyright (C) 1994-1998 T. Teranishi
	All Rights Reserved.

KEYCODE.EXE is a utility which displays key codes used in the
Tera Term's keyboard setup file. This text describes the usage of
KEYCODE.EXE and the format of keyboard setup file.

Please read this text and Tera Term help for changing the keyboard
configuration. Please do not ask the author questions about the
keyboard configuration.

-------------------------------------------------------------------------------
1. INSTALLATION
 
If you are using Windows 3.1 or NT 3.X, install KEYCODE.EXE
in Program Manager with its icon. If you are using Windows 95
or Windows NT 4.0, create a shortcut for KEYCODE.EXE in a folder
of your choice, in the Start menu or on the desktop.

-------------------------------------------------------------------------------
2. USAGE

When you run KEYCODE.EXE, the message "Push any key" will be displayed
in the window.	When you press a key or a combination of keys (such as
Ctrl+key), the message "Key code is XXXX." will be displayed. XXXX is a
decimal number.

-------------------------------------------------------------------------------
3. ABOUT THE KEYBOARD SETUP FILE

The keyboard setup file assigns keys on PC keyboard for various functions
such as VT terminal functions, sending user defined character strings,
executing Tera Term commands and executing macro files.

The default keyboard setup stored in the file KEYBOARD.CNF is almost
compatible with VT terminal keyboard. You can modify key assignments
by editing the file.

The file name of keyboard setup file to be loaded by Tera Term can be
specified as a command line parameter of Tera Term (see Tera Term help).
If you omit the file name extension, the default extension ".CNF" is used.
If you omit the file name, the default file KEYBOARD.CNF is loaded.

...............................................................................
3.1 FORMAT OF THE KEYBOARD SETUP FILE

Each key or key combination has a unique key code, which is called
"PC key code". 

The keyboard setup file has six sections:  [VT editor keypad],
[VT numeric keypad], [VT function keys], [X function keys], [Shortcut keys]
and [User keys].

1) [VT editor keypad] section
In this section, VT editor keys are assigned to PC keys.

	Format:
		<VT editor key name>=<PC key code>

	where:

	<VT editor key name>
		Up, Down, Right, Left, Find, Insert, Remove, Select,
		Prev, Next

	  <PC key code>
		PC key code (decimal number)

	Example:
		Up=328

2) [VT numeric keypad] section
In this section, VT numeric keys are assigned to PC keys.

	Format:
		<VT numeric key name>=<PC key code>

	where:

	  <VT numeric key name>
		Num0, Num1, Num2, Num3, Num4, Num5, Num6, Num7, Num8,
		Num9, NumMinus, NumComma, NumPeriod, NumEnter, PF1,
		PF2, PF3, PF4

	  <PC key code>
		PC key code (decimal number)

	Example:
		Num0=82

3) [VT function keys] section
In this section, VT function keys are assigned to PC keys.

	Format:
		<VT function key name>=<PC key code>

	where:

	  <VT function key name>
		(Function keys of VT terminal)
		Hold, Print, Break, F6, F7, F8, F9, F10, F11, F12,
		F13, F14, Help, Do, F17, F18, F19, F20
		("User defined keys" of VT terminal)
		UDK6, UDK7, UDK8, UDK9, UDK10, UDK11, UDK12, UDK13,
		UDK14, UDK15, UDK16, UDK17, UDK18, UDK19, UDK20

	  <PC key code>
		PC key code (decimal number)

	Example:
		F6=64

4) [X function keys] section
In this section, Xterm F1-F5 keys are assigned to PC keys.

	Format:
		<Xterm function key name>=<PC key code>

	where:

	  <Xterm function key name>
		XF1, XF2, XF3, XF4, XF5

	  <PC key code>
		PC key code (decimal number)

	Example:
		XF1=59

5) [Shortcut keys] section
In this section, Tera Term functions are assigned to PC keys.

	Format:
		<Shortcut key name>=<PC key code>

	where:
	  <Shortcut key name>	Function
	  --------------------------------------------
	  EditCopy		[Edit] Copy command
	  EditPaste		[Edit] Paste command
	  EditPasteCR		[Edit] Paste<CR> command
	  EditCLS		[Edit] Clear screen command
	  EditCLB		[Edit] Clear buffer command
	  ControlOpenTEK	[Control] Open TEK command
	  ControlCloseTEK	[Control] Close TEK command
	  LineUp		Scrolls up screen by 1 line
	  LineDown		Scrolls down by 1 line
	  PageUp		Scrolls up by 1 page
	  PageDown		Scrolls down by 1 page
	  BuffTop		Scrolls screen to buffer top
	  BuffBottom		Scrolls screen to buffer bottom
	  NextWin		Moves to the next Tera Term window
	  PrevWin		Moves to the previous Tera Term window
	  LocalEcho		Toggles the local echo status

	  <PC key code>
		PC key code (decimal number)

	Example:
		LineUp=1352

6) [User keys] section
This section defines user keys for functions, sending a character
string, executing a macro file or executing a menu command.

	Format:
		<User key name>=<PC key code>,<Control flag>,
				<Character string>

	where:

	  <User key name>
		User1, User2, User3,...., User99
		Maximum number of user keys is 99. 
		For example, if you want to define ten user keys,
		you must use the first ten names, from "User1" to "User10".

	  <PC key code>
		PC key code (decimal number)

	  <Control flag>
		Control flag which specifies how <character string>
		is treated when the PC key is pressed.
			0	<Character string> is sent as it is.
			1	New-line codes in <Character string>
				are converted by Tera Term and
				the converted string is sent.
			2	A macro file which has the name of
				<Character string> is executed.
			3	A Tera Term menu command specified
				by the menu ID <Character string> is
				executed.

	  <Character string>
		If <Control flag> is 0 or 1, <Character string>
		represents the character string to be sent.
		A non-printable character (control character) in
		the string can be expressed as a "$" and ASCII code
		in two-character hex number. For example, CR character
		is expressed as "$0D". "$" itself is expressed as "$24".
		See "Appendix A  ASCII CODE TABLE".

		If <Control flag> is 2, <Character string> specifies
		the macro file name to be executed.

		If <Control flag> is 3, <Character string> is the menu
		ID which specifies the menu command to be executed.
		The menu ID should be expressed as a decimal number.
		See "Appendix B  LIST OF MENU IDs".

	Example:
		User1=1083,0,telnet myhost
		User2=1084,0,$0D$0A
		User3=1085,1,$0D
		User4=1086,2,test.ttl
		User5=1087,3,50110

...............................................................................
3.2 NOTE

You can use a PC key code only once in the setup file.
If you use a PC key code for multiple key assignments,
the warning message "Key code XXX is used more than once" is
displayed when the file is loaded by Tera Term. In this case,
one of the assignments becomes effective and others are ignored.

If you don't want to assign a key item to any PC key,
use the word "off" like the following:

EditCopy=off

...............................................................................
3.3 KEY COMBINATIONS

The following key combinations are acceptable to Tera Term and KEYCODE.EXE:

	Shift+key
	Ctrl+key
	Shift+Ctrl+key
	Shift+Alt+key
	Ctrl+Alt+key
	Shift+Ctrl+Alt+key

Since some combinations (such as Alt+key) are used as shortcut keys of
Tera Term and Windows, they don't have PC key codes and can't be specified
in the keyboard setup file.

...............................................................................
3.4 Q & A

If you are in trouble with the keyboard configuration, please
read this text and Tera Term help carefully.
Please do not ask the author questions about the keyboard configuration.

Q. Everytime I run Tera Term, the warning message
   "Key code XXX is used more than once" is displayed.
A. See "3.2 NOTE".

Q. I want to use the PC "F1" key as the VT100 PF1 key. I edit the 
   keyboard setup file like the following but it does not work:

   [VT function keys]
   F1=PF1		(This is wrong.)

A. The left hand side can not be the name of a **PC key** but
   the name of a **VT terminal key**. The right hand side can not be
   the name of a key but a PC key code.
   See "3.1 FORMAT OF THE KEYBOARD SETUP FILE".
   You should also be careful not to specify a PC key code more than
   once in the setup file (see "3.2 NOTE").

   Edit the keyboard setup file like the following:

   [VT function keys]
   PF1=59			(59 is the keycode for the F1 key.)
   [X function keys]
   ;XF1=59			(Avoid specifying 59 twice.)
   XF1=off			(Replace 59 by "off".)

Q. How to edit the keyboard setup file to assign the F1 key
   for sending the escape sequence "ESC [ A"?
A. You can send any character string by using a user key.
   See "3.1 FORMAT OF THE KEYBOARD SETUP FILE".
   You should also be careful not to specify a PC keycode more than
   once in the setup file (see "3.2 NOTE").

   Edit the keyboard setup file like the following:

   [X function keys]
   ;XF1=59			(59 is the keycode for the F1 key.)
				(Avoid specifying 59 twice.)
   XF1=off			(Replace 59 by "off".)
   [User keys]
   User1=59,0,$1B[A		(The ASCII code for ESC is $1B.)

-------------------------------------------------------------------------------
APPENDIX A	ASCII CODE TABLE (HEXADECIMAL REPRESENTATION)

For example, the ASCII code for "A" is $41.

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

...............................................................................
APPENDIX B	LIST OF MENU IDs

See "3.1 FORMAT OF THE KEYBOARD SETUP FILE" for specifying a menu ID.
Menu IDs may be changed in future.

1) VT window

Menu command			ID
-------------------------------------
[File] New connection		50110
[File] Log			50120
[File] Send file		50130
[File] Transfer/Kermit/Receive	50141
[File] Transfer/Kermit/Get	50142
[File] Transfer/Kermit/Send	50143
[File] Transfer/Kermit/Finish	50144
[File] Transfer/XMODEM/Receive	50145
[File] Transfer/XMODEM/Send	50146
[File] Transfer/ZMODEM/Receive	50151
[File] Transfer/ZMODEM/Send	50152
[File] Transfer/B-Plus/Receive	50153
[File] Transfer/B-Plus/Send	50154
[File] Transfer/Quick-VAN/Receive 50155
[File] Transfer/Quick-VAN/Send	50156
[File] Change dir		50170
[File] Print			50180
[File] Disconnect		50190
[File] Exit			50199
[Edit] Copy			50210
[Edit] Copy table		50220
[Edit] Paste			50230
[Edit] PasteCR			50240
[Edit] Clear screen		50250
[Edit] Clear buffer		50260
[Setup] Terminal		50310
[Setup] Window			50320
[Setup] Font			50330
[Setup] Keyboard		50340
[Setup] Serial port		50350
[Setup] TCPIP			50360
[Setup] General 		50370
[Setup] Save setup		50380
[Setup] Restore setup		50390
[Setup] Load key map		50395
[Control] Reset terminal	50410
[Control] Are you there 	50420
[Control] Send break		50430
[Control] Reset port		50440
[Control] Open TEK		50450
[Control] Close TEK		50460
[Control] Macro 		50470
[Window] Window 		50810
[Help] Index			50910
[Help] Using			50920
[Help] About			50990

2) TEK window

Menu command			ID
-------------------------------------
[File] Print			51110
[File] Exit			51190
[Edit] Copy			51210
[Edit] Copy screen		51220
[Edit] Paste			51230
[Edit] PasteCR			51240
[Edit] Clear Screen		51250
[Setup] Window			51310
[Setup] Font			51320
[VTWin] 			51410
[Window] Window 		50810
[HELP] Index			51910
[HELP] Using			51920
[HELP] About			51990
