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

Re: Switching keys around

On Sun, Mar 18, 2001 at 10:13:02AM -0800, Heather wrote:
> > On Sat, 17 Mar 2001, Joanne Hunter wrote:
> > > 2) How can I do the same under the Linux console? (Is it possible?)
> > 
> > Yes, it's possible. I don't know how, though, and think it involves
> > editing the keymap files and loading them. Read the documentation on the
> > `console-tools' (or `kbd', if you have that installed instead) packages,
> > they /may/ help.
> > 
> >         Daniel
> There is a directory where alternative keymaps are kept (for example, Dvorak).
> You can copy the one for qwerty and add your own things, or change them.  Of
> course the normal keymaps are .gz so you need to ungzip them first ... but 
> after that they are plaintext and it made good sense to me, at least.  Plus,
> in my experience, the new one wouldn't work until I gzipped it again.

 You have to gzip again because /etc/init.d/keymaps-lct.sh specifies the .gz
extension, instead of just giving the base name, and letting loadkeys add
the .gz if there isn't an un-gzipped one.

 I spend enough time on the console that I've spent some time figuring out
the programs in console-tools, so I'll pass along what I've figured out:
 There's two ways go about making changes to the console keymap.  One way is
to edit /etc/console-tools/default.kmap.  This has the disadvantage of not
recording what you changed, and requiring more hacking if an upgrade to
console-tools-data has a new keymap (this hasn't happened happened to me
since I've been running debian, though...).  To swap any keys, use showkey
to find out their numbers, then edit default.kmap and swap the numbers in
the "keycode" lines.  e.g. to swap the "6" and "7" keys that are above the
alphabetic keys, find the lines:

keycode   7 = six              asciicircum     
	control	keycode   7 = Control_asciicircum
	alt	keycode   7 = Meta_six        
	shift	alt	keycode   7 = Meta_asciicircum
keycode   8 = seven            ampersand        braceleft        Control_underscore
	alt	keycode   8 = Meta_seven      
	shift	alt	keycode   8 = Meta_ampersand  
	control	alt	keycode   8 = Meta_Control_underscore

and change them to:

keycode   7 = seven            ampersand        braceleft        Control_underscore
	alt	keycode   7 = Meta_seven      
	shift	alt	keycode   7 = Meta_ampersand  
	control	alt	keycode   7 = Meta_Control_underscore
keycode   8 = six              asciicircum     
	control	keycode   8 = Control_asciicircum
	alt	keycode   8 = Meta_six        
	shift	alt	keycode   8 = Meta_asciicircum

 There will only be a single line for simpler keys like "Insert", and "Alt".

 Instead of changing /etc/console-tools/default.kmap, you can override parts
of it.  One of the directories loadkeys searches by default is
/usr/local/share/keymaps, so that's a good place to put stuff.  I have two
files there:

keycode 58 = Control
keycode 29 = Control
keycode 97 = Control
keycode 125 = Alt
keycode 126 = Alt
keycode 127 = Alt

(this is on an x86 desktop machine).

 Then, change /etc/init.d/keymaps-lct.sh to load a base keymap ("us" in my
case) , and the "patch" files you want.  Mine (with cruft removed) is:

case "$1" in
    start | restart | force-reload | reload)
        /bin/loadkeys us ctrl_nocaps windowskeys
        echo "Usage: $0 {start|stop|restart|reload|force-reload}"
        exit 1

 the .kmap extension is added by default, and gzipped files are handled
automatically, by loadkeys.

 (BTW, ctrl_nocaps makes caps lock be control.  This makes a standard PC
keyboard have control in the Right place, which is where the wrong-headed PC
kbd designers usually place the much-less-useful caps-lock key.  I named it
after the Xkbd option that does that for XF86, IIRC.  windowskeys assigns
all three of the suckers to be Alt.)

 On my old computers without windoze keys, I make the right alt key be alt
instead of altgr, so I can hold it with my thumb while I use the arrow keys
to switch consoles.  This lets me switch consoles with one hand.  If you
are a boring english-speaker like me, you probably won't ever use altgr for

 Hope this helps.

#define X(x,y) x##y
Peter Cordes ;  e-mail: X(peter@llama.nslug. , ns.ca)

"The gods confound the man who first found out how to distinguish the hours!
 Confound him, too, who in this place set up a sundial, to cut and hack
 my day so wretchedly into small pieces!" -- Plautus, 200 BCE

Reply to: