Switching Caps Lock and Control on the keyboard (assuming you use
keymaps 0-15; check with dumpkeys | head -1)
        % loadkeys
        keymaps 0-15
        keycode 58 = Control
        keycode 29 = Caps_Lock
        %
        % xmodmap .xmodmaprc
.xmodmaprc contains lines
        remove Lock = Caps_Lock
        remove Control = Control_L
        keysym Control_L = Caps_Lock
        keysym Caps_Lock = Control_L
        add Lock = Caps_Lock
        add Control = Control_L
Something else people like to change are the bindings of the function keys. Suppose that you want to make F12 produce the string "emacs ". Then
        % loadkeys
        keycode 88 = F12
        string F12 = "emacs "
        %
        % dumpkeys > my_keymap
        % cp my_keymap trial_keymap
        % emacs trial_keymap
        % loadkeys trial_keymap
        %
dumpkeys, and is documented in keymaps(5).
When the new keymap functions as desired, you can put an invocation
        loadkeys my_new_keymap
/etc/rc.local or so, to execute it automatically at boot-up.
Note that changing modifier keys is tricky, and a newbie can easily
get into a situation only an expert can get out of.
The default directory for keymaps is /usr/lib/kbd/keymaps.
The default extension for keymaps is .map.
For example, loadkeys uk would probably load
/usr/lib/kbd/keymaps/i386/qwerty/uk.map.
(With kbd-0.95 and older this would be /usr/lib/kbd/keytables
and /usr/lib/kbd/keytables/uk.map.)
(On my machine) /dev/console is a symbolic link to /dev/tty0,
and the kernel regards /dev/tty0 as a synonym for the current VT.
XFree86 1.3 changes the owner of /dev/tty0, but does not reset this
after finishing. Thus, loadkeys or dumpkeys might fail because
someone else owns /dev/tty0;
in such a case you might run X first.
Note that you cannot change keyboard mappings when not at the console
(and not superuser).
"Can the Shift, Ctrl and Alt keys be made to behave as toggles?"
Yes, after saying
        % loadkeys
        keymaps 0-15
        keycode 29 = Control_Lock
        keycode 42 = Shift_Lock
        keycode 56 = Alt_Lock
        %
"What about `sticky' modifier keys?"
Since version 1.3.33, the kernel knows about `sticky' modifier keys. These act on the next key pressed. So, where one earlier needed the 3-symbol sequence Shift_Lock a Shift_Lock to type `A', one can now use the 2-symbol sequence SShift_Lock a. You can say
        % loadkeys
        keymaps 0-15
        keycode 54 = SShift
        keycode 97 = SCtrl
        keycode 100 = SAlt
        %
The keymaps line in these examples should cover all keymaps you have in use. You find what keymaps you have in use by
        % dumpkeys | head -1
X
The following text was contributed by Piotr Mitros.
XFree86 supports an accessibility option which allows disabled users to type single-handed. With sticky keys enabled, the user can hit a modifier key (ctrl, alt, shift) followed by another key, rather than having to hold the modifier key while hitting the letter.
To enable sticky keys, first make sure the xkb extension is enabled
(this is done during initial X server configuration and is usually
enabled by default). Next, run the X server with the +accessx
option. If you use startx, either run startx -- +accessx or
add +accessx to the serverargs line in the startx script.
If you use xdm, add +accessx to the appropriate server line
in /etc/X11/xdm/Xservers.
It is also possible to enable X accessibility with some end-user
utilities with a running X server.
Once X accessibility is enabled, press the shift key five times in a
row to enable sticky keys. To disable sticky keys, either press the
shift key five times again, or press a key while holding a modifier
key.
XFree86 also supports Slow Keys, Repeat Keys, Bounce Keys and an
audible bell. xkbcomp can be used to generate a .xkm file
to enable these. The appropriate xkbcomp commands are listed in
/usr/X11R6/lib/X11/xkb/compat/accessx.
Unfortunately, the exact process is still undocumented.