Next: , Up: Keystrokes

9.1 Key Maps

All keystrokes exist inside a keymap. When you press the prefix key you are accessing the `root' keymap. By default all commands reside in the `root' key map and are accessed by pressing C-t.

There is also a top level key map, `top'. Any keystroke in this key map can be accessed simply by pressing the key. This is where the prefix key resides.

The following example adds a C-x b key binding to switch windows, much like C-x b in Emacs. See the functions below for full descriptions.

     # Create the key map
     newkmap ctrl-x
     # Bind b to 'select' on our new key map
     definekey ctrl-x b select
     # Attach our keymap to the top level key map via C-x.
     definekey top C-x readkey ctrl-x

The following functions control creating, editing, and deleting key maps.

— Command: newkmap kmap

Create a new keymap named kmap.

— Command: delkmap kmap

Delete the keymap, kmap.

— Command: bind Key command

Bind a key to a ratpoison command on the `root' keymap. This command takes two arguments: the key to bind and the command to run. For example, to bind C-t R to restart ratpoison:

          bind R restart
— Command: unbind key

Unbind a keystroke on the `root' keymap.

— Command: definekey kmap key command

definekey works exactly like bind except that it can bind keys on any key map (not just `root').

— Command: undefinekey kmap key

Like unbind except that you pass it a key map in kmap.

— Command: readkey kmap

Read a key from the keyboard and execute the command associated with it in the keymap, kmap.

— Command: link key

Call the command that key is bound to. For instance link C-t would call the command other and switch to the last window.

— Command: describekey keymap

An interactive way to find the command bound to a given key on the specified keymap. This command will wait for the user to type a key. When the user does, the command will display the command bound to this key.

— Command: set topkmap kmap

Set the top level keymap to kmap. You might use this to swap between several common keymappings or to implement modes.