The ANSI system can be used to reassign keys on the keyboard. When an application calls KbdStringIn, the reassigned key's ASCII code is converted to the specified string and is passed back to the calling application. For example, replace a with q so that whenever the a key is pressed, a q is passed to the application that is reading input.
In OS/2 2.1, keyboard remapping can be done only from an application calling KbdStringIn. In DOS, keyboard remapping must be done from the command line.
Note: Keyboard reassignment works only with OS/2 applications that use the KbdStringIn call to get input.
OS/2 mode ANSI is affected when keys are reassigned in a code-page environment. ANSI "remembers" the code page under which a key is reassigned. The keyboard subsystem checks for reassigned keys when the application calls the KbdStringIn function. When a reassigned key is detected, the ANSI support:
A maximum storage of 64KB can be allocated to OS/2 mode ANSI-reassigned key definitions. The table shown below contains the control sequences used to redefine the meaning of keyboard keys:
ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿³ The control sequence is: ³Function ³ ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³ ESC [#;#;...#p ³The first ASCII code in the ³ ³or ESC ["string"p ³control sequence defines which ³ ³or ESC [#;"string";#;#; ³code is being mapped. The ³ ³ "string";#p ³remaining numbers define the ³ ³or any other combination ³sequence of ASCII codes ³ ³ of strings and decimal ³generated when this key is ³ ³ numbers ³intercepted. However, if the ³ ³ ³first code in the sequence is ³ ³ ³0 (NULL), the first and second ³ ³ ³code make up an extended ASCII ³ ³ ³redefinition. ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
To execute the examples below, either create a file that contains the following statements and then use the TYPE command to display the file that contains the statement, or execute the command at the OS/2 prompt:
Using a File:
ESC [65;8lp A becomes Q ESC [97;113p a becomes q ESC [81;65p Q becomes A ESC [113;97p q becomes a
At the OS/2 Prompt:
prompt $e[65;8lp A becomes Q prompt $e[97;113p a becomes q prompt $e[81;65p Q becomes A prompt $e[113;97p q becomes a
Using a File:
ESC [0;68;"dir";13p
At the OS/2 Prompt:
prompt $e[0;68;"dir";13p
The $e is the prompt command characters for ESC. The 0;68 is the extended ASCII code for the F10 key; 13 decimal is a carriage return.
prompt $e[s$e[1;30f$e[K$p$e[u$n$g
If the current directory is C:\FILES, and the current drive is C, this example would display:
C:\FILES C>
TITLE SET ANSI.ASM - SET F10 TO STRING FOR ANSI.SYS CSEG SEGMENT PARA PUBLIC 'CODE' ASSUME CS:CSEG,DS:CSEG ORG 100H ENTPT: JMP SHORT START STRING DB 27,'[0;68;"DIR B:";13P' ;Redefine F10 key STRSIZ EQU $-STRING ;Length of above message HANDLE EQU 1 ;Pre-defined file. ;Handle for standard output START PROC NEAR MOV BX,HANDLE ;Standard output device MOV CX,STRSIZ ;Get size of text to be sent MOV DX,OFFSET STRING ;Pass offset of string ;To be sent MOV AH,40H ;Function="write to device" INT 21h ;Call DOS RET ;Return to DOS START ENDP CSEG ENDS END ENTPT