Xterm Keymapping Tips

Several folks have asked at various times on comp.windows.x for help setting up xterm to emulate vt220- and vt320-style keys under Linux and XFree86. Several other folks have been waiting silently, hoping someone would post such a solution. [Insert fanfare here.] Here it is ... sort of. Read on.

Below are (1) a listing of `translations', i.e. X resource settings which map X `keysyms' to actual keystrokes (usually only for a specific X client); and (2) a diagram illustrating how the LinuX console maps to the `standard' vt220/vt320 keys using the listed translations. Not necessarily in that order.

Disclaimer

My translations work for:

Xterm already deals with the cursor keys in some fashion. My translations do not deal with: I have tested my translations on Linux with XFree86 version 2.x and XFree86 version 3.x using the stock configuration. If you have made extensive changes to the X keyboard mapping (using xmodmap or xkeycaps or a similar utility), these translations may not work.

Your mileage may vary.

Map of VT220/VT320 Keys to LinuX Console

The following diagram shows which vt220/vt320 keys are produced by which keystrokes on the LinuX console using the *XTerm*VT100.translations resource setting below. [Note that this resource setting causes vt220/vt320 keystrokes to be produced only for xterm---you need to set a separate translations resource for each X client you want to use vt220/vt320 keystrokes with.]

+-------------------+
| vt220/vt320 key   |
|                   |
| LinuX console key |  S-<key> = Shift+<key>
+-------------------+

Function Keys

     +------+------+------+------+------+       ** = these function keys are 
     |  f1  |  f2  |  f3  |  f4  |  f5  | ...        local function keys only
     |      |      |      |      |      |            on both vt220 and vt320 
     |  **  |  **  |  **  |  **  |  **  | ...        terminals (i.e., Setup, 
     +------+------+------+------+------+            Break, &c.)             

     +------+------+------+------+------+  +------+------+------+------+     
 ... |  f6  |  f7  |  f8  |  f9  |  f10 |  | f11  | f12  | f13  | f14  | ... 
     |      |      |      |      |      |  |      |      |      |      |     
 ... |  f6  |  f7  |  f8  |  f9  |  f10 |  | S-f1 | S-f2 | S-f3 | S-f4 | ... 
     +------+------+------+------+------+  +------+------+------+------+     

             +-------------+------------+  +------+------+------+------+
         ... | f15  or Help| f16  or Do |  | f17  | f18  | f19  | f20  |
             |             |            |  |      |      |      |      |
         ... | S-f5 or f11 | S-f6 or f12|  | S-f7 | S-f8 | S-f9 | S-f10|
             +-------------+------------+  +------+------+------+------+

Keypad

     +-------+-------+-------+----------+
     |  pf1  |  pf2  |  pf3  |  pf4     |
     |       |       |       |          |
     |  f1   |  f2   |  f3   |  f4      |
     +-------+-------+-------+----------+
     |  kp7  |  kp8  |  kp9  |  kpminus |
     |       |       |       |          |
     |  kp7  |  kp8  |  kp9  |  kpminus |
     +-------+-------+-------+----------+
     |  kp4  |  kp5  |  kp6  |  kpcomma |
     |       |       |       |          |
     |  kp4  |  kp5  |  kp6  |  kpplus  |
     +-------+-------+-------+----------+
     |  kp1  |  kp2  |  kp3  |          |
     |       |       |       |          |
     |  kp1  |  kp2  |  kp3  |  kpenter |
     +-------+-------+-------+          |
     |  kp0  |  kpperiod     |  kpenter |
     |       |               |          |
     |  kp0  |  kpperiod     |          |
     +-------+---------------+----------+

Xterm Translations Resource Listing

  • Text version of resource listing, suitable for adding directly to a .Xdefaults file.
  • !! xterm keymappings
    *XTerm*VT100.translations:      #override \n\
            None<Key>KP_0: string(0x1b) string("Op") \n\
            None<Key>KP_1: string(0x1b) string("Oq") \n\
            None<Key>KP_2: string(0x1b) string("Or") \n\
            None<Key>KP_3: string(0x1b) string("Os") \n\
            None<Key>KP_4: string(0x1b) string("Ot") \n\
            None<Key>KP_5: string(0x1b) string("Ou") \n\
            None<Key>KP_6: string(0x1b) string("Ov") \n\
            None<Key>KP_7: string(0x1b) string("Ow") \n\
            None<Key>KP_8: string(0x1b) string("Ox") \n\
            None<Key>KP_9: string(0x1b) string("Oy") \n\
            None<Key>KP_Add: string(0x1b) string("Ol") \n\
            None<Key>KP_Subtract: string(0x1b) string("Om") \n\
            None<Key>KP_Decimal: string(0x1b) string("On") \n\
            None<Key>KP_Enter: string(0x1b) string("OM") \n\
            None<Key>F11: string(0x1b) string("[28~") \n\
            None<Key>F12: string(0x1b) string("[29~") \n\
            None<Key>F1: string(0x1b) string("OP") \n\
            None<Key>F2: string(0x1b) string("OQ") \n\
            None<Key>F3: string(0x1b) string("OR") \n\
            None<Key>F4: string(0x1b) string("OS") \n\
            None<Key>F5: string(0x1b) string("[E") \n\
            None<Key>F6: string(0x1b) string("[17~") \n\
            None<Key>F7: string(0x1b) string("[18~") \n\
            None<Key>F8: string(0x1b) string("[19~") \n\
            None<Key>F9: string(0x1b) string("[20~") \n\
            None<Key>F10: string(0x1b) string("[21~") \n\
            Shift<Key>F1: string(0x1b) string("[23~") \n\
            Shift<Key>F2: string(0x1b) string("[24~") \n\
            Shift<Key>F3: string(0x1b) string("[25~") \n\
            Shift<Key>F4: string(0x1b) string("[26~") \n\
            Shift<Key>F5: string(0x1b) string("[28~") \n\
            Shift<Key>F6: string(0x1b) string("[29~") \n\
            Shift<Key>F7: string(0x1b) string("[31~") \n\
            Shift<Key>F8: string(0x1b) string("[32~") \n\
            Shift<Key>F9: string(0x1b) string("[33~") \n\
            Shift<Key>F10: string(0x1b) string("[34~") \n\
    

    Copyright © 1996-2000 Jim Knoble and Liquid Meme. All rights reserved.