X keyboard extension
Encyclopedia
In human-computer interfaces, the X keyboard extension or XKB is a part of the X Window System
that extends the ability to control the keyboard
over what is offered by the X Window System core protocol. The main features of this extension are:
The extension is composed of two parts: a server extension and a client library. Modern versions of Xlib
contain XKB, which is active by default. Client programs not using this extension can deactivate it before connecting with the server, or can simply work normally as the extension simulates the core protocol by default.
. However, a modifier may also be locked, like the Caps Lock
modifier. In particular, when a modifier is locked it remains active until it is explicitly deactivated. An intermediate condition between regular and locked is the latched state: when a modifier is latched it remains active, but only until the next non-modifier key is pressed.
XKB allows a client application to explicitly latch or lock a modifier. Moreover, an application can bind a key press or release to a modifier state change. This way, a modifier may automatically become latched or locked whenever a key is pressed or released.
XKB defines some group selectors (which are simply called groups in the specification). As with modifiers, a group selector can be associated with a key, but can also be latched or locked.
The above two controls are boolean
: they are either active or not. The PerKeyRepeat is a control that is not boolean. Namely, it is a mask that says which keys are in autorepeat mode. According to the specification, non-boolean controls are "always active": that means that they always depends on a set of parameters (in this case, the mask), but that there is no single bit that can be used to deactivate the effects of the control completely.
Other than being boolean or non-boolean, controls also classifies as affecting the behavior of the server and affecting the behavior of the client library. The two above are server controls. Client library controls affect the translation of a keycode or a sequence of keycodes into a string (XLookupString) and event delivery.
Moreover, there are some actions related to devices that are available if the server supports the X Input extension.
XKB also improves upon the core protocol's handling of bells; the core protocol only supports one bell and the only action a client can perform is to ring the bell. XKB supports multiple named bells and allows a client to deactivate some of them and to be informed when a bell is rung.
XKB allows a client to query the physical shape of the keyboard, including the shapes of individual keys. In particular, keys are arranged into sections, possibly rotated (as an example, the numeric keypad is typically considered a section). Within a section, keys are arranged into rows. Keys and sections have a geometry, which comprise the approximate outline of the key, its bounding box, and the precise form. Other than keys, the geometry also includes doodads, which are elements on the keyboard that are not keys. The overall shape of the keyboard is a doodad. Information provided about doodads includes their color and any text printed on them (including the font used).
X Window System
The X window system is a computer software system and network protocol that provides a basis for graphical user interfaces and rich input device capability for networked computers...
that extends the ability to control the keyboard
Computer keyboard
In computing, a keyboard is a typewriter-style keyboard, which uses an arrangement of buttons or keys, to act as mechanical levers or electronic switches...
over what is offered by the X Window System core protocol. The main features of this extension are:
- enhanced support for modifierModifier keyIn computing, a modifier key is a special key on a computer keyboard that modifies the normal action of another key when the two are pressed in combination....
s; - better treatment of key groups;
- extended control of keyboard indicators (LEDLEdLEd is a TeX/LaTeX editing software working under Microsoft Windows. It is a freeware product....
s) and bellBell characterA bell code is a device control code originally sent to ring a small electromechanical bell on tickers and other teleprinters and teletypewriters to alert operators at the other end of the line, often of an incoming message...
s; - various new keyboard parameters (controls);
- association of actions (of a particular kind) to keys;
The extension is composed of two parts: a server extension and a client library. Modern versions of Xlib
Xlib
Xlib is an X Window System protocol client library written in the C programming language. It contains functions for interacting with an X server. These functions allow programmers to write programs without knowing the details of the protocol...
contain XKB, which is active by default. Client programs not using this extension can deactivate it before connecting with the server, or can simply work normally as the extension simulates the core protocol by default.
Latched and locked modifiers
XKB allows a modifier to be locked or latched, other than being in its regular state. Normally, a modifier is active exactly when it is pressed, like the ShiftShift key
The shift key is a modifier key on a keyboard, used to type capital letters and other alternate "upper" characters. There are typically two shift keys, on the left and right sides of the row below the home row...
. However, a modifier may also be locked, like the Caps Lock
Caps lock
Caps lock is a key on many computer keyboards. Pressing it sets an input mode in which typed letters are uppercase by default. The keyboard remains in caps lock mode until the key is pressed again...
modifier. In particular, when a modifier is locked it remains active until it is explicitly deactivated. An intermediate condition between regular and locked is the latched state: when a modifier is latched it remains active, but only until the next non-modifier key is pressed.
XKB allows a client application to explicitly latch or lock a modifier. Moreover, an application can bind a key press or release to a modifier state change. This way, a modifier may automatically become latched or locked whenever a key is pressed or released.
Key groups
XKB allows for the keyboard to switch between any of four different character groups. This is usually done for making a keyboard behave like a keyboard of a different language. In this context, the set of characters that is generated by the keyboard is called a group, and a keyboard can switch to a different group at any time.XKB defines some group selectors (which are simply called groups in the specification). As with modifiers, a group selector can be associated with a key, but can also be latched or locked.
Controls
The behavior of the keyboard depends on a number of parameters that can be changed by the clients. These parameters are called controls. For example, the SlowKey control can be used to ignore short keypresses. Another control is the MouseKeys, which makes some keypresses to simulate mouse movements. The control only indicates whether this simulation is active or not; which keys produce the movement is not considered a part of the control, but is specified by attaching actions to these keys.The above two controls are boolean
Boolean
Boolean may refer to:* Boolean algebra, a logical calculus of truth values or set membership* Boolean algebra , a set with operations resembling logical ones* Boolean data type, a certain datatype in computer science...
: they are either active or not. The PerKeyRepeat is a control that is not boolean. Namely, it is a mask that says which keys are in autorepeat mode. According to the specification, non-boolean controls are "always active": that means that they always depends on a set of parameters (in this case, the mask), but that there is no single bit that can be used to deactivate the effects of the control completely.
Other than being boolean or non-boolean, controls also classifies as affecting the behavior of the server and affecting the behavior of the client library. The two above are server controls. Client library controls affect the translation of a keycode or a sequence of keycodes into a string (XLookupString) and event delivery.
Actions
XKB allows for associating actions with key presses, which moves some of the burden of input event processing from client applications to the X server. However, the actions that can be associated with keys are limited to the following:- Change the state of a modifier, making it active, deactive, latched or locked
- Change the state of the group selectors (same as modifiers)
- Simulate a mouse event (movement or button activity)
- Change the active screen (this kind of action is optional, that is, not necessarily supported by the server)
- Change the state of boolean controls
- Generate a message event (that is, a packet that is sent to the client)
- Generate a different keycode
Moreover, there are some actions related to devices that are available if the server supports the X Input extension.
Other
XKB allows for better handling of the keyboard indicators (LEDs). In particular, XKB provides symbolic names for indicators, which allows for binding indicators to keyboard activity and checking which indicators are actually present on the keyboard.XKB also improves upon the core protocol's handling of bells; the core protocol only supports one bell and the only action a client can perform is to ring the bell. XKB supports multiple named bells and allows a client to deactivate some of them and to be informed when a bell is rung.
XKB allows a client to query the physical shape of the keyboard, including the shapes of individual keys. In particular, keys are arranged into sections, possibly rotated (as an example, the numeric keypad is typically considered a section). Within a section, keys are arranged into rows. Keys and sections have a geometry, which comprise the approximate outline of the key, its bounding box, and the precise form. Other than keys, the geometry also includes doodads, which are elements on the keyboard that are not keys. The overall shape of the keyboard is a doodad. Information provided about doodads includes their color and any text printed on them (including the font used).
External links
- Creating custom keyboard layouts for X11 using XKB
- Detailed information on the various XKB Configuration files
- An Unreliable Guide to XKB Configuration
- On xkb2
- Re-designing input methods with XKB - a blog article in 2009 by an X input interface developer
- http://article.gmane.org/gmane.comp.freedesktop.xorg/39976 – mailing list followup about XKB2
- XKB2 dreams - a page on xkb2 random notes in freedesktop.org