Skip to Content.
Sympa Menu

baslinux - Re: [BL] Notes on X11 keyboard mapping

baslinux AT lists.ibiblio.org

Subject: Baslinux mailing list

List archive

Chronological Thread  
  • From: <keesan2 AT cyberspace.org>
  • To: <baslinux AT lists.ibiblio.org>
  • Subject: Re: [BL] Notes on X11 keyboard mapping
  • Date: Mon, 12 May 2003 13:15:40 -0400 (EDT)

I finally got up the courage to attempt to remap my keyboard.

First, I tried to use xev (which is included in the Slackware
X distribution) with my window manager, ratpoison. No matter
how much I moved the mouse around or clicked it nothing at all happened
except for that little square appearing.

So I changed .xinitrc to read not 'ratpoison' but 'xterm' and
then everything worked. I typed 'xev' and got a very small square
over a larger blank square over a still larger square with writing
in it over the patterned background that I got because xterm was not
set by default to be full size. Moving the mouse around produced
a lot of text as described in the email below.

Then I typed the various keys that I was interested in remapping,
and the keys I wanted them to act like. I copied down only
the part that showed the keycode and keysymm:

Backspace key: Code 22 Keysym 0xffff, Delete
Delete #2 (not on the numpad): Code 107, Keysym 0xffff, Delete
Del #1 (on the numpad): Code 91 Keysym 0xffae, KP_decimal

So this explains why the backspace acts just like the Delete key and
why the Del key does not act like the Delete key but rather like
the decimal point key.

I also looked up all the other keys on the numpad: four arrow keys
(Up Down Right Left), Insert, Home, End, PgUp and PgDn (Prior and
Next).

I then tried to understand this business about make a file, but
there was nothing about what to call the file or what to do with it,
so I looked for xmodmap* and found xmodmap.std which it said
to feed to xmodmap to restore the defaults. I made a copy of this
as xmodmap.84 and changed the keysyms of all the keys on the numpad.
They are the same when used with or without the shift key so I only typed
in one thing for each one instead of unshifted and also shifted.
The format was not exactly the same as suggested below (no '=')
and you don't need to type in all the 0xffff's, just the Insert or Prior.

Eventually I learned to 'feed' xmodmap.
First load X with an xterm and type in the xterm window
(while in the same directory as xmodmap.84)

xmodmap xmodmap.84

After I did this the left and right arrow keys and backspace and both
deletes worked properly in the xterm!!! I then loaded flwriter and tested
the up and down arrows and PgUp and PgDn and they work too. I have not
yet tested this in Opera. No way to test Home and End.

I am really delighted to have my 84-key keyboard usable with X now.
Even my 102-key keyboard was not behaving properly before (no backspace).

Many many thanks for the explanation of what all these words mean
and how to actually remap a keymap. Other people had said to use
xev but I had no idea what to do with it or xmodmap.

I automated this by putting into .xinitrc before 'xterm' the line
xmodmap /var/X11R6/lib/etc/xmodmap.84. (Have not checked if it
works when I replace xterm with ratpoison).

I still need to find some keys to which to map F11 and F12, probably
the - and + on the numpad since they are duplicated. F11 is
useful in Opera to remove the banner ad (and everything else other
than the actual webpage).

Off the subject, but since the BL2 kernel cannot be used with sound, can I
have TWO linux kernels (zimage and zimage2) in my DOS directory and two
different batch files (boot and boot2) to load them, so as to load the
larger kernel only if I want to play with Realaudio? (That and the
scanner are my only reasons left for keeping a Windows computer).
What kernel would I need if not bare.i, to be able to load a sound module
(SB16)?

On Sun, 27 Apr 2003 ruohtula AT netscape.net wrote:

> Someone asked about the xmodmap file syntax. Maybe that got sorted
> out but reading the list I get the feeling the following might be useful
> for some people new to Linux and X11.
>
> I haven't yet tried to use X11 on Basiclinux, but I have
> tinkered with X11 keyboard mappings on various other unixlike platforms,
> so maybe I can offer some hints on how to get a keyboard
> to behave.
>
> The generals idea in X11 is that when you hit a key, it sends a "keycode"
> to the X11 server. These are hardware dependent. X11 toolkit libraries
> and applications normally do not use them (that would make them hardware-
> dependent). Instead the X11 server converts the keycodes to "keysyms"
> which can be seen as a hardware-independent description of what key was
> hit. The X11 programs then act on these.
>
> The xmodmap program can be used to manipulate the keycode-to-keysym
> mapping. This is usually the best way to make a key change behavior,
> because it affects all X11 programs (but sometimes you want a key
> remapping to affect only a particular program, and then you have to use
> something specific to the program, like setting a resource string for
> xterm).
>
> The main problem with redefining keysyms is figuring out what key
> produces which keycode. X11 has a program called "xev" that is a
> help here. (Unfortunately some Linux distributions omit it, I don't know
> if Slackware 7.1 has it). Create a xterm window and type "xev" there.
> Don't put it in the background.
> The xev program creates a window that just contains a square
> Make the window have the keyboard focus (click it or just move mouse
> there, depending on how your window manager is set up) and hit keys.
> You will see text lines like:
>
> MotionNotify event, serial 27, synthetic NO, window 0x2a00001,
> root 0x3e, subw 0x0, time 3486608963, (115,115), root:(119,135),
> state 0x0, is_hint 0, same_screen YES
>
> appear in the xterm window. They list "events" that the xev program
> gets from X11 (it is very educational to see how they correspond
> to mouse operations!). Stop your mouse and hit the keys you are interested
> in. You see something like this:
>
> KeyPress event, serial 27, synthetic NO, window 0x2c00001,
> root 0x3e, subw 0x0, time 3486777276, (107,171), root:(111,191),
> state 0x0, keycode 38 (keysym 0x61, a), same_screen YES,
> XLookupString gives 1 characters: "a"
>
> KeyRelease event, serial 27, synthetic NO, window 0x2c00001,
> root 0x3e, subw 0x0, time 3486777348, (107,171), root:(111,191),
> state 0x0, keycode 38 (keysym 0x61, a), same_screen YES,
> XLookupString gives 1 characters: "a"
>
> This was for hitting the A key. You see it has keycode 38. Use this to
> get the codes for the keys you want to remap. Then go to the xterm and hit
> ctrl-C to kill the xev program.
>
> Then you can make a file with a line like
>
> keycode <keycode> = <unshifted> <shifted>
>
> where <keycode> is the keycode, <unshifted> is the keysym it sends by
> default and <shifted> when shift is down. Actually there can be at least
> for some keys added keysyms for AltGR down and Shift-AltGr down, but
> you don't need to specify them and I am not sure if they work in all
> keyboards or X11 servers. The bit on modifier declarations
> is not quite clear to me yet. Should investigate.
>
> You can get a textual dump of your current keymap by typing
>
> xmodmap -pke
>
> This gives you an idea of what keysym names there are (and keycodes
> as well).
>
> I hope the above is useful to someone, and not totally wrong...
>
> Erkki
>
> PS: I read this lists from the digests and not very often,
> so if you comment on the above, I will probably not respond until
> after a day or two.
>
>
>
>
>
> _______________________________________________
> BasLinux mailing list
> BasLinux AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/baslinux
>





Archive powered by MHonArc 2.6.24.

Top of Page