Next: , Previous: , Up: Top   [Contents][Index]

18 Keymaps

Keymaps are used to associate events with commands. When an event occurs, the associated command is found and evaluated. A keymap is simply a list whose first element is the symbol keymap.

Function: keymapp arg

Returns t if arg may be used as a keymap.

Function: make-keymap

Returns a newly-created empty keymap.

Function: bind-keys keymap &rest bindings

Installs zero or more key bindings into the keymap keymap, then returns keymap.

Each binding is defined by two elements in the list of bindings, the first defines the name of an event (or the event itself) and the second defines the command to be associated with the event.

For example to bind two keys in the keymap keymap; the event C-f to the command foo and the event C-b to the command bar the following form would be used,

(bind-keys keymap
 "C-f" 'foo
 "C-b" 'bar)

Currently, multiple keystrokes can’t be bound with a single bind-keys call. Instead, bind an event to another keymap.

Function: unbind-keys keymap &rest keys

Removes the bindings of the events keys (these may be the names of the events or the event objects themselves) from the keymap keymap.

Functions bind-keys and unbind-keys do not affect the bindings of existing windows, because keymaps are set on a window when the window is created and begins to be managed by Sawfish. Update can be done by following functions.

Function: grab-keymap keymap
Function: ungrab-keymap keymap

All bindings stored in keymap get into / out of effect of all windows, including root, but not of frame parts.

Notice that ungrab-keymap has to be called BEFORE you change the keymap.

If the window foo has its own keymap rather than window-keymap, then it is not affected by (grab-keymap window-keymap).

Function: search-keymap event keymap

Search for a binding of the event event in keymap. If a binding is found a cons cell (command . event) is returned.

There are several pre-defined keymaps that are always available:


Keymap containing bindings active anywhere.


Keymap containing bindings active when a client window is focused.


Keymap containing bindings active when the pointer is in the root window.


Keymaps active in the title and borders of window frames.


Keymaps active in the standard window frame buttons.


Must be a keymap, a symbol, or nil. If it is a keymap, this becomes the keymap in which all lookups occur (overriding the window, root and global keymaps). If it is a symbol, Sawfish finds the symbol’s value and tries again. If it is nil, Sawfish behaves normally.

Next: , Previous: , Up: Top   [Contents][Index]