	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 and BackTab key are assigned to PC keys.

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

	where:

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

	  <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
	  NextShownWin		Moves to the next Tera Term window (except minimized)
	  PrevShownWin		Moves to the previous Tera Term window (except minimized)
	  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.

[NOTE]
You can specify `Alt+key' combination when Alt key uses meta key. Check
`Meta key' under Keyboard of Setup menu. The key code can be obtained by
KEYCODE.EXE, unfortunately the key code of `Alt+key' combination can not
be obtained. Also, you obtain the key code and add 2048 on the value.

For example, the `V' key code is 47, also `Alt+V' key code is 2095.

; Shift + Insert
EditPaste=850

If you change above entry to `EditPaste=2095', you can paste by using
`Alt+V' on condition that Meta key is pass through.

You add in the following entry to [User keys] section in KEYBOARD.CNF if
you wan to paster by using `Alt+V' remaining `Shift+Insert' function.

User1=2095,3,50230

...............................................................................
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] Duplicate session            50111
[File] Cygwin connection            50112
[File] Log                          50120
[File] Comment to Log               50121
[File] View Log                     50122
[File] Show Log dialog              50123
[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/YMODEM/Receive      50157
[File] Transfer/YMODEM/Send         50158
[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] Replay Log                   50171
[File] LogMeTT                      50172
[File] Print                        50180
[File] Disconnect                   50190
[File] Exit                         50199
[File] Exit All                     50200
[Edit] Copy                         50210
[Edit] Copy table                   50220
[Edit] Paste                        50230
[Edit] PasteCR                      50240
[Edit] Clear screen                 50250
[Edit] Clear buffer                 50260
[Edit] Cancel selection             50270
[Edit] Select screen                50280
[Edit] Select all                   50290
[Setup] Terminal                    50310
[Setup] Window                      50320
[Setup] Font                        50330
[Setup] Keyboard                    50340
[Setup] Serial port                 50350
[Setup] TCPIP                       50360
[Setup] General                     50370
[Setup] Additional settings         50375
[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] Broadcast command         50445
[Control] Open TEK                  50450
[Control] Close TEK                 50460
[Control] Macro                     50470
[Control] Show Macro Window         50480
[Window] Window                     50810
[Window] Minimize All               50811
[Window] Restore All                50812
[Window] Cascade                    50813
[Window] Stacked                    50814
[Window] Side by Side               50815
[Window] Undo - XXX                 50816
[Help] Index                        50910
[Help] About Tera Term              50990

TTSSH Menu command                  ID
-----------------------------------------
[Setup] SSH                         52310
[Setup] SSH Authentication          52320
[Setup] SSH Forwarding              52330
[Setup] SSH KeyGenerator            52340
[Help] About TTSSH                  52910

TTProxy Menu command                ID
-----------------------------------------
[Setup] Proxy                       53310
[Help] About TTProxy                53910

TTXKanjiMenu Menu command           ID
-----------------------------------------
[KanjiCode] Recv: Shift_JIS         54010
[KanjiCode] Recv: EUC-JP            54011
[KanjiCode] Recv: JIS               54012
[KanjiCode] Recv: UTF-8             54013
[KanjiCode] Recv: UTF-8m            54014
[KanjiCode] Send: Shift_JIS         54110
[KanjiCode] Send: EUC-JP            54111
[KanjiCode] Send: JIS               54112
[KanjiCode] Send: UTF-8             54113
[KanjiCode] Use one setting         54200

TTXAlwaysOnTop Menu command         ID
-----------------------------------------
[Control] Always on top             55000
-- SetWindowPos(HWND_TOP)           55001 (not in menu)
-- SetWindowPos(HWND_BOTTOM)        55002 (not in menu)
-- SetWindowPos(HWND_TOPMOST)       55003 (not in menu)
-- SetWindowPos(HWND_NOTOPMOST)     55004 (not in menu)

TTXResizeMenu Menu command          ID
-----------------------------------------
[Resize] Menu(1) - Menu(20)         55101 - 55120

TTXViewMode Menu command            ID
-----------------------------------------
[Setup] ViewMode password           55200
[Control] View mode                 55210

TTXttyrec Menu command              ID
-----------------------------------------
[File] TTY Record                   55301

TTXttyplay Menu command             ID
-----------------------------------------
[File] TTY Replay                   55302

TTXRecurringCommand Menu command    ID
-----------------------------------------
[Setup] Recurring Command           55500
[Control] Recurring Command         55501
-- Enable Recurring Command         55502 (not in menu)
-- Disable Recurring Command        55503 (not in menu)


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                     51810
[HELP] Index                        51910
[HELP] About Tera Term              51990
