1XGrabKey(3) XLIB FUNCTIONS XGrabKey(3)
2
3
4
6 XGrabKey, XUngrabKey - grab keyboard keys
7
9 int XGrabKey(Display *display, int keycode, unsigned int modifiers,
10 Window grab_window, Bool owner_events, int pointer_mode, int
11 keyboard_mode);
12
13 int XUngrabKey(Display *display, int keycode, unsigned int modifiers,
14 Window grab_window);
15
17 display Specifies the connection to the X server.
18
19 grab_window
20 Specifies the grab window.
21
22 keyboard_mode
23 Specifies further processing of keyboard events. You can
24 pass GrabModeSync or GrabModeAsync.
25
26 keycode Specifies the KeyCode or AnyKey.
27
28 modifiers Specifies the set of keymasks or AnyModifier. The mask is
29 the bitwise inclusive OR of the valid keymask bits.
30
31 owner_events
32 Specifies a Boolean value that indicates whether the keyboard
33 events are to be reported as usual.
34
35 pointer_mode
36 Specifies further processing of pointer events. You can pass
37 GrabModeSync or GrabModeAsync.
38
40 The XGrabKey function establishes a passive grab on the keyboard. In
41 the future, the keyboard is actively grabbed (as for XGrabKeyboard),
42 the last-keyboard-grab time is set to the time at which the key was
43 pressed (as transmitted in the KeyPress event), and the KeyPress event
44 is reported if all of the following conditions are true:
45
46 · The keyboard is not grabbed and the specified key (which can
47 itself be a modifier key) is logically pressed when the specified
48 modifier keys are logically down, and no other modifier keys are
49 logically down.
50
51 · Either the grab_window is an ancestor of (or is) the focus window,
52 or the grab_window is a descendant of the focus window and con‐
53 tains the pointer.
54
55 · A passive grab on the same key combination does not exist on any
56 ancestor of grab_window.
57
58 The interpretation of the remaining arguments is as for XGrabKeyboard.
59 The active grab is terminated automatically when the logical state of
60 the keyboard has the specified key released (independent of the logical
61 state of the modifier keys), at which point a KeyRelease event is
62 reported to the grabbing window.
63
64 Note that the logical state of a device (as seen by client applica‐
65 tions) may lag the physical state if device event processing is frozen.
66
67 A modifiers argument of AnyModifier is equivalent to issuing the
68 request for all possible modifier combinations (including the combina‐
69 tion of no modifiers). It is not required that all modifiers specified
70 have currently assigned KeyCodes. A keycode argument of AnyKey is
71 equivalent to issuing the request for all possible KeyCodes. Other‐
72 wise, the specified keycode must be in the range specified by min_key‐
73 code and max_keycode in the connection setup, or a BadValue error
74 results.
75
76 If some other client has issued a XGrabKey with the same key combina‐
77 tion on the same window, a BadAccess error results. When using AnyMod‐
78 ifier or AnyKey, the request fails completely, and a BadAccess error
79 results (no grabs are established) if there is a conflicting grab for
80 any combination.
81
82 XGrabKey can generate BadAccess, BadValue, and BadWindow errors.
83
84 The XUngrabKey function releases the key combination on the specified
85 window if it was grabbed by this client. It has no effect on an active
86 grab. A modifiers of AnyModifier is equivalent to issuing the request
87 for all possible modifier combinations (including the combination of no
88 modifiers). A keycode argument of AnyKey is equivalent to issuing the
89 request for all possible key codes.
90
91 XUngrabKey can generate BadValue and BadWindow error.
92
94 BadAccess A client attempted to grab a key/button combination already
95 grabbed by another client.
96
97 BadValue Some numeric value falls outside the range of values accepted
98 by the request. Unless a specific range is specified for an
99 argument, the full range defined by the argument's type is
100 accepted. Any argument defined as a set of alternatives can
101 generate this error.
102
103 BadWindow A value for a Window argument does not name a defined Window.
104
106 XAllowEvents(3), XGrabButton(3), XGrabKeyboard(3), XGrabPointer(3)
107 Xlib - C Language X Interface
108
109
110
111X Version 11 libX11 1.6.4 XGrabKey(3)