You are not logged in.

#1 2019-03-15 03:30:53

doums
Member
Registered: 2019-03-15
Posts: 9

[Solved] keycode 58 = Escape has 0 effect

Hi,

I'm trying to map the CapsLock key to Escape only for console.
So I followed the doc without any changes and any success sad
What I did:

/usr/local/share/kbd/keymaps/personal.map

include "/usr/share/kbd/keymaps/i386/azerty/fr-pc.map.gz"

keycode 58 = Escape

/etc/vconsole.conf

KEYMAP="/usr/local/share/kbd/keymaps/personal.map"

I have checked the key code of CapsLock which is 58, with the following:

# showkey -k
kb mode was ?UNKNOWN?
[ if you are trying this under X, it might not work
since the X server is also reading /dev/console ]

press any key (program terminates 10s after last keypress)...
keycode  28 release
keycode  58 press
keycode  58 release
keycode  58 press
keycode  58 release

And finally I reloaded successfully the config with loadkeys /usr/local/share/kbd/keymaps/personal.map and even with restarting the laptop -> 0 change at all neutral


I also tried directly under X with xmodmap and ~/.Xmodmap:

clear lock
keycode 66 = Escape

And it works perfectly but the CapsLock key is mapped to Escape in the whole X and that's not what I want.

Why it does not work for virtual console ?
Note: I also tried by replacing 58 by 66 but no success too

Infos:

localectl status
   System Locale: LANG=fr_FR.UTF-8
       VC Keymap: /usr/local/share/kbd/keymaps/personal.map
      X11 Layout: fr
       X11 Model: pc
sudo dumpkeys -k | grep 58
keycode  58 = Escape          
	shift	altgr	keycode  58 = VoidSymbol      
	shift	control	keycode  58 = VoidSymbol      
	shift	altgr	control	keycode  58 = VoidSymbol      
	shift	alt	keycode  58 = VoidSymbol      
	altgr	alt	keycode  58 = VoidSymbol      
	shift	altgr	alt	keycode  58 = VoidSymbol

Linux 5.0.0-arch1-1-ARCH #1 SMP PREEMPT Mon Mar 4 14:11:43 UTC 2019 x86_64 GNU/Linux

Last edited by doums (2019-03-15 13:35:58)

Offline

#2 2019-03-15 07:37:32

seth
Member
Registered: 2012-09-03
Posts: 12,332

Re: [Solved] keycode 58 = Escape has 0 effect

Since it looks a lot like you're on an X11 session, please clarify what you're trying to do:
alter the escape key on a VTE in X11 (xterm, urxvt, terminator, konsole, gnome-terminal, …) or on the linux console (multi-user.target, no GUI stuff whatsoever)?

Also this sounds like an xy-problem. What itch do you ultimately want to scratch?

Offline

#3 2019-03-15 09:16:27

doums
Member
Registered: 2019-03-15
Posts: 9

Re: [Solved] keycode 58 = Escape has 0 effect

I want to replace the capslock key by escape to use with any terminal emulator like terminator and xfce4-terminal (I use the first one).
I'm on Xfce4 4.12, terminator 1.91

Last edited by doums (2019-03-15 09:45:18)

Offline

#4 2019-03-15 09:44:13

jbenge1
Member
From: Milano
Registered: 2018-04-09
Posts: 149

Re: [Solved] keycode 58 = Escape has 0 effect

I remapped my <capslock> key to the <home> (as I don't have a dedicated home key) in X11 by first installing xxkb, then editing /usr/share/X11/xkb/symbols/us <- because I am using the us keyboard

here is the updated file

/usr/share/X11/xkb/symbols/us
___________________________________

default  partial alphanumeric_keys modifier_keys
xkb_symbols "basic" {

    name[Group1]= "English (US)";
    key <INS> {        [     KP_End,   KP_Ins           ]       };

    key <TLDE> {    [     grave,    asciitilde  ]   };
    key <AE01> {    [     1,    exclam      ]   };
    key <AE02> {    [     2,    at      ]   };
    key <AE03> {    [     3,    numbersign  ]   };
    key <AE04> {    [     4,    dollar      ]   };
    key <AE05> {    [     5,    percent     ]   };
    key <AE06> {    [     6,    asciicircum ]   };
    key <AE07> {    [     7,    ampersand   ]   };
    key <AE08> {    [     8,    asterisk    ]   };
    key <AE09> {    [     9,    parenleft   ]   };
    key <AE10> {    [     0,    parenright  ]   };
    key <AE11> {    [     minus,    underscore  ]   };
    key <AE12> {    [     equal,    plus        ]   };
    key <CAPS> {    [     KP_Home,  KP_Home ]       }; ##The line of interest ##

    key <AD01> {    [     q,    Q       ]   };
    key <AD02> {    [     w,    W       ]   };
    key <AD03> {    [     e,    E       ]   };
    key <AD04> {    [     r,    R       ]   };
    key <AD05> {    [     t,    T       ]   };
    key <AD06> {    [     y,    Y       ]   };
    key <AD07> {    [     u,    U       ]   };
    key <AD08> {    [     i,    I       ]   };
    key <AD09> {    [     o,    O       ]   };
    key <AD10> {    [     p,    P       ]   };
    key <AD11> {    [ bracketleft,  braceleft   ]   };
    key <AD12> {    [ bracketright, braceright  ]   };

    key <AC01> {    [     a,    A       ]   };
    key <AC02> {    [     s,    S       ]   };
    key <AC03> {    [     d,    D       ]   };
    key <AC04> {    [     f,    F       ]   };
    key <AC05> {    [     g,    G       ]   };
    key <AC06> {    [     h,    H       ]   };
    key <AC07> {    [     j,    J       ]   };
    key <AC08> {    [     k,    K       ]   };
    key <AC09> {    [     l,    L       ]   };
    key <AC10> {    [ semicolon,    colon       ]   };
    key <AC11> {    [ apostrophe,   quotedbl    ]   };

    key <AB01> {    [     z,    Z       ]   };
    key <AB02> {    [     x,    X       ]   };
    key <AB03> {    [     c,    C       ]   };
    key <AB04> {    [     v,    V       ]   };
    key <AB05> {    [     b,    B       ]   };
    key <AB06> {    [     n,    N       ]   };
    key <AB07> {    [     m,    M       ]   };
    key <AB08> {    [     comma,    less        ]   };
    key <AB09> {    [    period,    greater     ]   };
    key <AB10> {    [     slash,    question    ]   };

    key <BKSL> {    [ backslash,         bar    ]   };
};

I'm sure there is a more intelligent way but for me it works at the moment

*Note: I found the key codes in /usr/share/X11/xkb/keycodes/evdev


"Dr. Madden, why don't the natural numbers include 0?" -me
"....... Take a philosophy course" -Dr. Madden

Offline

#5 2019-03-15 10:22:20

doums
Member
Registered: 2019-03-15
Posts: 9

Re: [Solved] keycode 58 = Escape has 0 effect

Ok so the problem was I thought that setting /etc/vconsole.conf to an extended keymap will set stuff for terminal emulator but it's wrong because (if I understand well), using /etc/vconsole.conf only sets the mapping for linux console, not terminal emulation (which run in X session).

So alter the X mapping is the good way to go, for example using ~/.Xmodmap like described in the main post.

Thank you all.

Last edited by doums (2019-03-15 10:26:55)

Offline

#6 2019-03-15 12:06:52

seth
Member
Registered: 2012-09-03
Posts: 12,332

Re: [Solved] keycode 58 = Escape has 0 effect

vconsole.conf only sets the mapping for linux console

Yup.

There's actually an xkb option "caps:swapescape" or "caps:escape" which you could use rather than xmodmap (adding that option to your xorg conf will maintain the behavior when the keyboard gets re-added, eg. after an S3)

Limiting the effect to a VTE is gonna be tricky ("impossible") because caps lock acts as a toggle for the shift modifier (ie. this is not a "real" key)

For "normal" keys at least xterm allows to override their behavior, eg.

xterm.vt100.translations: #override <Key>KP_Delete:string(.)

can be handy for numpad centric xterms outside US locales.

Offline

#7 2019-03-15 13:34:03

doums
Member
Registered: 2019-03-15
Posts: 9

Re: [Solved] keycode 58 = Escape has 0 effect

Ok thanks for these tips!

I replaced .Xmodmap file by /etc/X11/xorg.conf.d/01-keyboard.conf (which extends my base keyboard config 00-keyboard.conf)  with

Section "InputClass"
    Identifier "capslock to escape"
    MatchIsKeyboard "on"
    Option "XKbOptions" "caps:escape"
EndSection

And it works perfectly

Offline

Board footer

Powered by FluxBB