Using ANSI.SYS /X to Remap Extended Keys (83064)



The information in this article applies to:
    Microsoft MS-DOS operating system 4.0
    Microsoft MS-DOS operating system 4.01
    Microsoft MS-DOS operating system 5.0
    Microsoft MS-DOS operating system 5.0a
    Microsoft MS-DOS operating system 6.0
    Microsoft MS-DOS operating system 6.2
    Microsoft MS-DOS operating system 6.21
    Microsoft MS-DOS operating system 6.22

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;"dir";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;"dir";13p $e[224;71;"CLS";13p $p$g
NOTE: The lowercase "p" 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.

REFERENCES

"Microsoft MS-DOS User's Guide and Reference," version 5.0, page 593

Modification Type: Major Last Reviewed: 5/12/2003
Keywords: KB83064