[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.2 Binding Keys

Function: define-key map key command

Add a keybinding mapping for the key, key, to the command, command, in the specified keymap. If command is nil, remove an exising binding. For example,

 
(stumpwm:define-key stumpwm:*root-map* (stumpwm:kbd "C-z") "echo Zzzzz...")

Now when you type C-t C-z, you’ll see the text “Zzzzz...” pop up.

Function: undefine-key map key

Clear the key binding in the specified keybinding.

Function: kbd keys

This compiles a key string into a key structure used by ‘define-key’, ‘undefine-key’, ‘set-prefix-key’ and others.

Command: set-prefix-key key

Change the stumpwm prefix key to KEY.

 
(stumpwm:set-prefix-key (stumpwm:kbd "C-M-H-s-z"))

This will change the prefix key to <Control> + <Meta> + <Hyper> + <Super> + the <z> key. By most standards, a terrible prefix key but it makes a great example.

Function: make-sparse-keymap

Create an empty keymap. If you want to create a new list of bindings in the key binding tree, this is where you start. To hang frame related bindings off C-t C-f one might use the following code:

 
(defvar *my-frame-bindings*
  (let ((m (stumpwm:make-sparse-keymap)))
    (stumpwm:define-key m (stumpwm:kbd "f") "curframe")
    (stumpwm:define-key m (stumpwm:kbd "M-b") "move-focus left")
    m ; NOTE: this is important
  ))

(stumpwm:define-key stumpwm:*root-map* (stumpwm:kbd "C-f") '*my-frame-bindings*)
Variable: *root-map*

This is the keymap by default bound to C-t. It is known as the prefix map.

Variable: *top-map*

The top level key map. This is where you’ll find the binding for the prefix map.

Variable: *groups-map*

The keymap that group related key bindings sit on. It is bound to C-t g by default.

Command: bind key command

Hang a key binding off the escape key.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on January 28, 2024 using texi2html 1.82.