merge the C branch into HEAD
[mikachu/openbox.git] / doc / python / keyboard.txt
1 input.Keyboard
2
3 ----
4
5 This document describes the 'Keyboard' class, exposed by Openbox's 'input'
6 module to its python scripts.
7
8 All keyboard events which will be generated because of the Keyboard class can
9 be caught from the hooks.keyboard hook.
10
11 ----
12
13 Methods
14
15 ----
16
17 bind(keychain, func)
18
19 Binds a key-chain to a function. The keychain is a tuple of strings which
20 define a chain of key presses. Each member of the tuple has the format
21 [Modifier-]...[Key]. Modifiers can be 'mod1', 'mod2', 'mod3', 'mod4', 'mod5',
22 'control', and 'shift'. The keys on your keyboard that are bound to each of
23 these modifiers can be found by running 'xmodmap'. The Key can be any valid
24 key definition. Key definitions can be found by running 'xev', pressing the
25 key while its window is focused, and watching its output. Here are some
26 examples of valid keychains: ('a'), ('F7'), ('control-a', 'd'),
27 ('control-mod1-x', 'control-mod4-g'), ('F1', 'space').
28 The func must have a definition similar to 'def func(keydata, client)'. The
29 arguments passed to the function are a KeyboardData object and a Client object.
30 A keychain cannot be bound to more than one function.
31
32         keychain: A tuple containing strings defining a chain of key presses.
33
34         func: A function to bind to the keychain.
35
36 ----
37
38 clearBinds()
39
40 Removes all bindings that were previously made by bind().
41
42 ----
43
44 grab(func)
45
46 Grabs the entire keyboard, causing all possible keyboard events to be passed
47 to the given function. CAUTION: Be sure when you grab() that you also have an
48 ungrab() that will execute, or you will not be able to type until you restart
49 Openbox. The func must have a definition similar to 'def func(keydata)'. The
50 argument passed to the function is a KeyboardData object. The keyboard cannot
51 be grabbed if it is already grabbed.
52
53         func: A function to receive all the grabbed keyboard events.
54
55 ----
56
57 ungrab()
58
59 Ungrabs the keyboard. The keyboard cannot be ungrabbed if it is not grabbed.