how to map Command key to Esc on X

Michael Baer yellowdog-general@lists.terrasoftsolutions.com
Tue Sep 2 16:04:01 2003


>>>>> "A" == Aurelio Marinho Jargas <aureliojargas@yahoo.com.br> writes:

    A> hi, i'm aurelio from brazil, this is my first message to the
    A> list.  i'm a happy YDL 3.0 user :)

    A> i use vim a lot, but this little Esc key on my ibook is just
    A> too little to be pressed everytime (as Vim requests).

    A> i think i don't use the Command key (the apple one), so i
    A> wanted to map it to Esc.

    A> i like linux on the text mode, so i've changed my current
    A> keyboard mapping "us-acentos" to do the maping:

    A>    $ gunzip -c /lib/kbd/keymaps/i386/qwerty/us-acentos.map.gz |
    A>      grep '^key.*Escape'

    A>    keycode 1 = Escape Escape keycode 125 = Escape Escape


    A> and it worked well. Esc'ing with the thumb rocks :)


    A> but as now i play with some mozilla and other graphic monsters,
    A> i wanted to do the same mapping under X.  i'm 100% Luser on X,
    A> and tryed to play with the xmodmap command.

    A> i've tryed 3 ways, but none worked under xterm.

    A> 1. created a ~/.xmodmaprc file with the following content:

    A>    keycode 125 = Escape

    A> 2. added the same line to /usr/X11R6/lib/X11/etc/xmodmap.std

    A> 3. executed the following command on WindowMaker autorun:

    A>    xmodmap -e "keycode 125 = Escape"

On my keyboard 115 is the apple key (A first generation Ti), 125 may
be the incorrect number.

You might try 'xev' it will open a window and any X events (including
key presses, but also mouse movements, etc...) in that window will
have their corresponding information output in the terminal you ran
xev from.

For example, pressing and releasing my command key shows:

KeyPress event, serial 22, synthetic NO, window 0x3800001,
    root 0x40, subw 0x0, time 347589777, (181,115), root:(1151,135),
    state 0x0, keycode 115 (keysym 0xffe9, Alt_L), same_screen YES,
    XLookupString gives 0 bytes:  ""

KeyRelease event, serial 27, synthetic NO, window 0x3800001,
    root 0x40, subw 0x0, time 347589869, (181,115), root:(1151,135),
    state 0x20, keycode 115 (keysym 0xffe9, Alt_L), same_screen YES,
    XLookupString gives 0 bytes:  ""

and my escape key gives:

KeyPress event, serial 22, synthetic NO, window 0x3800001,
    root 0x40, subw 0x0, time 347940608, (148,127), root:(1118,147),
    state 0x0, keycode 9 (keysym 0xff1b, Escape), same_screen YES,
    XLookupString gives 1 bytes:  "

KeyRelease event, serial 27, synthetic NO, window 0x3800001,
    root 0x40, subw 0x0, time 347940752, (148,127), root:(1118,147),
    state 0x0, keycode 9 (keysym 0xff1b, Escape), same_screen YES,
    XLookupString gives 1 bytes:  "


Notice: keycode 115 (keysym 0xffe9, Alt_L)
and:    keycode 9 (keysym 0xff1b, Escape)

You can use this to see more reliably what X thinks the keycode is for
a particular key on your machine.


Mike

-- 
ydl@mikesoffice.com