Microsoft KB Archive/83064

= Using ANSI.SYS /X to Remap Extended Keys =

Article ID: 83064

Article Last Modified on 5/12/2003

-

APPLIES TO


 * Microsoft MS-DOS 4.0 Standard Edition
 * Microsoft MS-DOS 4.01 Standard Edition
 * Microsoft MS-DOS 5.0 Standard Edition
 * Microsoft MS-DOS 5.0a
 * Microsoft MS-DOS 6.0 Standard Edition
 * Microsoft MS-DOS 6.2 Standard Edition
 * Microsoft MS-DOS 6.21 Standard Edition
 * Microsoft MS-DOS 6.22 Standard Edition

-



This article was previously published under Q83064



SUMMARY
Microsoft MS-DOS version 4.0 introduced a new feature to the ANSI.SYS console device driver, used by specifying the /X switch. With the /X switch, ANSI.SYS can distinguish the extended keys (RIGHT ARROW, HOME, and so on) from the keypad keys (with NUM LOCK off) on some extended keyboards. This allows you to redefine the keys separately using ANSI escape sequences. Extended keyboards are also called 101- or 102-key keyboards.

If you have an extended keyboard and want to redefine an extended key (or keypad key) without also redefining the corresponding keypad key (or extended key) to another character, you must load ANSI.SYS with the /X switch.



MORE INFORMATION
Non-ASCII keys (function keys, SHIFT keys, extended keys, and, when NUMLOCK is off, the keypad keys) differ from the ASCII keys in that they send an identifying code to the input buffer, followed by the key's value. ANSI.SYS recognizes this and reads the input buffer a second time after receiving the identifying scan code.

Most keyboards only send the 00H scan code for all non-ASCII keys. Many extended keyboards send a scan code of 0EH (224 decimal) for the extended keys and a 00H for the corresponding keypad keys. ANSI.SYS can only detect the difference between extended and keypad keys with the latter type of keyboard.

The following example remaps both HOME keys to issue the DIR command on an extended keyboard. In CONFIG.SYS:   device=c:\dos\ansi.sys In AUTOEXEC.BAT:   set prompt= $e[0;71;&quot;dir&quot;;13p $p$g The following example remaps the HOME key on the number pad to issue the DIR command, and the gray HOME key to issue the CLS command on an extended keyboard. Add the following to the CONFIG.SYS file:   device=c:\dos\ansi.sys /x In AUTOEXEC.BAT, add the following:   set prompt= $e[0;71;&quot;dir&quot;;13p $e[224;71;&quot;CLS&quot;;13p $p$g NOTE: The lowercase &quot;p&quot; characters in the above command must be lowercase. In the above commands, the space included before each dollar sign ($) is optional, and is only added for clarity.

