src/swipl-devel/packages/xpce/man/refmanual/md/key_binding.md

class key_binding {#class-key_binding}

Class key_binding is a subclass of class recogniser. It accepts keyboard events and maps them onto messages.

Class key_binding deals with

Key_binding objects are used by various classes that are sensitive to keyboard events: editor, text, text_item and list_browser.

Example {#class-key_binding-example}

The following example shows how a key_binding object may be used to make a graphical object editable using the mouse:

 ?- send(new(P, picture('Graphical editor')), open),
    send(P, display, new(B, box(100,100))),
    send(B, recogniser, new(K, key_binding(@nil, argument))),
    send(K, function, 'TAB',
         message(@receiver, inverted,
                 @receiver?inverted?negate)),
    send(K, function, '\C-d', free),
    send(K, function, '\C-p', pen).

Typing TAB (= control-I), the box is inverted; typing control-d will delete the graphical; typing META-3 control-p will make the pen (thickness) of the line 3. See <-argument on how to specify the universal numeric argument.

Organisation of the class {#class-key_binding-organisation-of-the-class}

How a key_binding parses a keyboard event is described with ->typed; The specification of symbolic key-names is described with ->function; Resolution of a binding from a symbolic key is described with<-function; Predefined binding tables are described with ->initialise. See also @key_bindings.

Library keybinding {#class-key_binding-library-keybinding}

The PCE/Prolog library file keybinding.pl defines the predicate show_key_bindings/1, which dumps the key_binding of objects or plain tables.

@see class list_browser @see class text_item @see class text @see class editor

Instance variables {#class-key_binding-instvars}

Send methods {#class-key_binding-send}

Get methods {#class-key_binding-get}



Try the rswipl package in your browser

Any scripts or data that you put into this service are public.

rswipl documentation built on June 16, 2026, 5:07 p.m.