[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Permanently swapping a key



I have an old laptop which I installed Debian on, but then discovered that the control key (CTRL) does not work at all. I can solve this by swapping control with the unused Windows key and using that key instead. I was able to reassign CTRL to the Windows key in X using xmodmap as follows ("Super_L" is the unused Windows key):

xmodmap -e "remove Control = Control_L"
xmodmap -e "remove Control = Control_R"
xmodmap -e "remove mod4 = Super_L"
xmodmap -e "keycode 115 = Super_L"
xmodmap -e "add Control = Super_L"

The problem is that this only works in X, and I would like to permanently reassign CTRL to the Windows key for console mode as well.


I was able to get it to remap these keys on boot, both in X and in the console. In case anyone else is interested, this is what I did (I'll indent commands and file contents for readability):

First, to remap the control key to the Windows key in X every time the X server is started, I added a new script to the /etc/X11/Xsession.d directory (I called it "60x11-custom-keys") containing the following:

    # Set Windows key (Super_L) to be CTRL (Control)
    xmodmap -e "remove Control = Control_L"
    xmodmap -e "remove Control = Control_R"
    xmodmap -e "remove mod4 = Super_L"
    xmodmap -e "keycode 115 = Super_L"
    xmodmap -e "add Control = Super_L"

Second, I modified the default console keymap file /etc/console/boottime.kmap.gz (I backed up the original, of course).

I uncompressed the file and edited it:

    gunzip /etc/console/boottime.kmap.gz
    vi /etc/console/boottime.kmap

Then I changed the following lines:

    keycode  29 = Control

    keycode  97 = Control

    keycode 125 =

    keycode 126 =

To:

    keycode  29 = Help
            altgr   control keycode 29 = VoidSymbol
            shift   alt     keycode 29 = VoidSymbol

    keycode  97 = Help
            altgr   control keycode 97 = VoidSymbol
            shift   alt     keycode 97 = VoidSymbol

    keycode 125 = Control

    keycode 126 = Control

I then gzipped the file again and reloaded it:

    gzip /etc/console/boottime.kmap
    loadkeys /etc/console/boottime.kmap.gz

And now my Windows key in my CTRL key all the time.

    - Dave

--

Dave Parker
Utica College Department of
Integrated Information Technology Services
Data Processing Office
(315) 792-3229
Registered Linux User #408177



Reply to: