This document describes the following [keymap] formats, as implemented by libxkbcommon:
@see For an overview of the role of this format, please see “@ref xkb-the-config ""”.
@see For examples of keymaps in this format, please see “@ref custom-configuration ""”. For further examples see xkeyboard-config, the standard database of keyboard configuration data.
@note Due to the complexity of the format, this document is still is construction. Some additional resources are:
@tableofcontents{html:2}
[terminology]: @ref terminology [introduction]: @ref introduction-to-the-xkb-text-format [xkb_keymap]: @ref the-xkb_keymap-block [xkb_keycodes]: @ref the-xkb_keycodes-section [xkb_types]: @ref the-xkb_types-section [xkb_compat]: @ref the-xkb_compat-section [xkb_symbols]: @ref the-xkb_symbols-section [virtual modifier statements]:@ref virtual-modifier-statements [actions]: @ref key-actions
Each modifier has an associated [encoding][modifier encoding]. In keymaps compatible with X11, the encoding can be interpreted as a mapping to one or multiple real modifier. Real modifiers map to themselves: they are [canonical modifiers][canonical modifier]. See the “@ref modifiers-encoding ""” section for further information.
The following table lists the predefined and usual modifiers present in the standard keyboard configuration. Note that this is provided for information only, as it may change depending on the user configuration.
| Modifier | Type | Predefined | Usual mapping | Comment |
| ------------ | -------------- | ---------- | ----------------- | --------------------------- |
| Shift | Real + Virtual | Yes (Core) | Shift (fixed) | The usual Shift |
| Lock | Real + Virtual | Yes (Core) | Lock (fixed) | The usual Caps Lock |
| Control | Real + Virtual | Yes (Core) | Control (fixed) | The usual Control |
| Mod1 | Real + Virtual | Yes (Core) | Mod1 (fixed) | Not conventional |
| Mod2 | Real + Virtual | Yes (Core) | Mod2 (fixed) | Not conventional |
| Mod3 | Real + Virtual | Yes (Core) | Mod3 (fixed) | Not conventional |
| Mod4 | Real + Virtual | Yes (Core) | Mod4 (fixed) | Not conventional |
| Mod5 | Real + Virtual | Yes (Core) | Mod5 (fixed) | Not conventional |
| Alt | Virtual | No | Mod1 | The usual Alt |
| Meta | Virtual | No | Mod1 | The legacy Meta key |
| NumLock | Virtual | No | Mod2 | The usual NumLock |
| Super | Virtual | No | Mod4 | The usual Super/GUI |
| LevelThree | Virtual | No | Mod5 | ISO level 3, aka AltGr |
| LevelFive | Virtual | No | Mod3 | ISO level 5 |
[core modifier]: @ref core-modifiers [extended modifier]: @ref extended-real-mod-def [usual modifiers]: @ref usual-modifiers
A modifier key can report its state in one of the following 3 ways:
<dt><a name="depressed-mod-def">Depressed</a></dt>
<dd>Active while logically depressed; e.g. the usual Shift.</dd>
<dt><a name="latched-mod-def">Latched</a></dt>
<dd>
Activated when pressed and released, then automatically deactivated
after the next key event that produces a symbol (i.e. a non-modifier
key press). Useful for one-shot modifier keys (e.g. a sticky Shift).
</dd>
<dt><a name="locked-mod-def">Locked</a></dt>
<dd>
Activated when pressed and deactivated when pressed again;
e.g. the usual Caps Lock.
</dd>
See [modifiers declaration and binding] for further details.
[depressed]: @ref depressed-mod-def [latched]: @ref latched-mod-def [locked]: @ref locked-mod-def
This various results are organized in an ordered list; the index
of each entry is called a shift level
or simply level. By convention the lowest level is the result when
no modifier is active.
Example for the key A on a latin script keyboard:
| Level | Description | Keysym | Active key modifiers |
|-------|--------------------------------|--------|----------------------|
| 1 | Lower case letters | a | None |
| 2 | Upper case letters. | A | Shift |
| 3 | Alternative lower case letters | ae | AltGr |
| 4 | Alternative upper case letters | AE | Shift + AltGr |
A key shift level is the logical state of a key corresponding to the current shift level it used.
Key shift levels are derived from the modifiers states, but not
necessarily in the same way for all keys. For example, for Latin
script the Caps Lock modifier selects the level 2 for alphabetic
keys such as A but has no effect on a numeric key.
There are groups of keys with the same characteristics: letters, punctuation, numeric keypad, etc. The meaning of their levels is identical and thus can be shared: this generalization is called a key type (see hereinafter).
ONE_LEVEL: the key has only one level, i.e. it is not affected
by any modifiers. Example: the modifiers themselves.TWO_LEVEL][TWO_LEVEL]: the key has two levels:
Shift modifier is not active.Shift modifier.FOUR_LEVEL][FOUR_LEVEL]: see the example in the previous section.See [xkb_types] for further details.
A user who deals with multiple languages may need two or more different layouts: e.g. a layout for Arabic and another one for English. In this context, layouts are called groups in XKB, as defined in the standard ISO/IEC 9995.
Layouts are ordered and identified by their index. Example:
Similarly to modifiers, layouts have depressed, latched and locked components, which are summed to give the effective layout. Unlike modifiers — which are masks, so multiple can be active simultaneously — only a single layout is active at any time, the components being numeric offsets or indices rather than bits.
@todo out-of-range layout policy xkb_layout_out_of_range_policy
@todo effective layout
Offsets the active layout by the given amount for as long as the
triggering key is physically held down, then the offset is removed.
Corresponds to a [`SetGroup`][SetGroup] action.
Offsets the active layout by the given amount when the triggering key
is pressed and released, then the offset is removed after the next
symbol-producing key press. Corresponds to a
[`LatchGroup`][LatchGroup] action.
Sets the active layout to the given index until explicitly changed
again. Corresponds to a [`LockGroup`][LockGroup] action. This is the
usual behaviour of a layout-switch key (e.g. toggling between a
Latin and a Greek layout).
See the section “[Key actions][actions]” for further details.
<dt><em>Physical</em> indicator</dt>
<dd>
Typically a labelled LED on the keyboard, e.g. “Caps Lock” and
“Num Lock”.
</dd>
<dt><em>Logical</em> indicator</dt>
<dd>
A customizable derived state of the keyboard.
Its changes creates events that can be monitored.
There are two categories:
- _Real_ indicators are those associated to a physical indicator.
For example, the “Caps Lock” logical modifier controls the
corresponding physical LED.
Because indicators are customizable, if one misses a “Num Lock”
LED, one could define instead the “Caps Lock” _indicator_ to
activate its LED when the “Num Lock” _modifier_ is active.
- _Virtual_ indicators are not associated to a physical indicator.
Their effect is only visible for programs monitoring them.
Note that the meanings of _real_ and _virtual_ is slightly
different than the one used for [modifier].
</dd>
See: [xkb_keycodes][indicator name] to define indicators and
[xkb_compat][indicator effect] to define their effects.
Depending of the context, a keymap may refer to:
See @ref keymap-components-intro and [xkb_keymap] for further details.
A database that provides the [keymap components](@ref keymap-components-intro).
\*nix OSs uses the _standard_ database [xkeyboard-config]. One may extend
this database with _custom_ layouts: see “@ref custom-configuration ""” for
further details.
[keycode]: @ref keycode-def [keysym]: @ref keysym-def [keysyms]: @ref keysym-def [modifier]: @ref modifier-def [modifiers]: @ref modifier-def [real modifier]: @ref real-modifier-def [real modifiers]: @ref real-modifier-def [virtual modifier]: @ref virtual-modifier-def [virtual modifiers]: @ref virtual-modifier-def [level]: @ref level-def [shift level]: @ref level-def [level index]: @ref level-index-def [key type]: @ref key-type-def [key types]: @ref key-type-def [layout]: @ref layout-def [action]: @ref key-action-def [indicator]: @ref indicator-def [keymap]: @ref keymap-def [database]: @ref database-def
The XKB text format uses a syntax similar to the C programming language. Note that the similarity with C stops here: the XKB text format is only a configuration format and is not intended for programming.
The XKB text format is used to configure a keyboard keymap, which is introduced in “@ref xkb-the-config ""”. It has the following two main use cases, illustrated in the diagram hereinafter:
@see xkb_keymap::xkb_keymap_new_from_names2
@see xkeyboard-config for the implementation of the standard keymap configuration database.
@see “@ref custom-configuration ""” to add a custom layout or option.
@see xkb_keymap::xkb_keymap_new_from_string
@anchor xkb-keymap-components-diagram @dotfile xkb-keymap-components "XKB text format use cases"
[RMLVO]: @ref RMLVO-intro [KcCGST]: @ref KcCGST-intro [complete keymap]: @ref keymap-intro
There are two kinds of files for the XKB text format:
[keymap file]: @ref keymap-file-def [keymap component file]: @ref keymap-component-file-def [keymap sections]: @ref keymap-section-def [section]: @ref keymap-section-def [keymap components]: @ref keymap-component-def
[Keymap components][keymap components] are described with [keymap sections]. They are grouped in [keymap component files][keymap component file] to form a [keyboard configuration database][database].
[keymap components table]: @ref keymap-components-table
@anchor keymap-components-table
Comments are introduced following either // or # until the end of the line.
"”.
The following _escape sequences_ are supported:
| Escape sequence | Meaning |
| ------------------ | -------------------------------------------------------- |
| `\\` | Backslash “`\`” |
| `\"` | Double quote “`"`” |
| `\b` | Backspace |
| `\e` | Escape |
| `\f` | Form feed |
| `\n` | Line feed (newline) |
| `\r` | Carriage return |
| `\t` | Horizontal tabulation |
| `\v` | Vertical tabulation |
| `\` + octal number | Corresponding ASCII character: `\1` → `SOH`, `\42` → `"`. Up to **4** octal digits `0‥7` are parsed. The result must fit into a byte. |
| `\u{` + hexadecimal number + `}` | `\u{NNNN}` produce the corresponding [Unicode code point] `U+NNNN`, encoded in [UTF-8]. Supported code points are in the range `U+0001‥U+10FFFF`. |
@note The string _encoding_ is unspecified and not validated, but for best
results, stick to ASCII.
@since \<1.9.0: Octal escape sequences accept up to **3** digits.
@since 1.9.0: Octal escape sequences accept up to **4** digits.
Added \\" and `\u{NNNN}` escape sequences.
[Keysyms][keysym] may be written in multiple ways:
| Keysym string | Keysym name | Keysym value |
|---|---|---|
| `""` | `NoSymbol` | `0x0000` |
| `"a"` | `a` | `0x0061` |
| `"ü"` | `udiaeresis` | `0x00dc` |
| `"🎺"` | `U1F3BA` | `0x0101F3BA` |
| `"g̃"` | `{g, combining_tilde}` | `{0x0101F3BA, 0x01000303}` |
The following table presents the keywords used in the format. They are case-sensitive.
| Keyword | Use |
|---|---|
action |
Action of an interpret statement |
alias |
Keycode alias |
alphanumeric_keys |
Section flag |
alternate_group |
Section flag |
alternate |
Merge mode qualifier for [include] statements |
augment |
Merge mode qualifier for [include] statements |
default |
Section flag |
deprecated |
Section flag |
function_keys |
Section flag |
group |
TODO |
hidden |
Section flag |
include |
[Include statement][include] |
indicator |
Indicator statement in either the keycode section or the compatibility section |
interpret |
[Interpret statement][interpret] |
key |
Key statement |
keypad_keys |
Section flag |
keys |
Legacy [geometry element][xkb_geometry] |
logo |
Legacy [geometry element][xkb_geometry] |
mod_map |
Alias of modifier_map |
modifier_keys |
Section flag |
modmap |
Alias of modifier_map |
modifier_map |
Real modifier bindings |
outline |
Legacy [geometry element][xkb_geometry] |
overlay |
Legacy [geometry element][xkb_geometry] |
override |
Merge mode qualifier for [include] statements |
partial |
Section flag |
replace |
Merge mode qualifier for [include] statements |
row |
Legacy [geometry element][xkb_geometry] |
section |
Legacy [geometry element][xkb_geometry] |
shape |
Legacy [geometry element][xkb_geometry] |
solid |
Legacy [geometry element][xkb_geometry] |
text |
Legacy [geometry element][xkb_geometry] |
type |
Key type statement |
virtual_modifiers |
Virtual modifiers mappings |
virtual |
Flag for the indicator statement |
xkb_compat_map |
Alias of xkb_compatibility_map |
xkb_compat |
Alias of xkb_compatibility_map |
xkb_compatibility_map |
Declare a [compatibility section][xkb_compat] |
xkb_compatibility |
Alias of xkb_compatibility_map |
xkb_geometry |
Declare a [geometry section][xkb_geometry] |
xkb_keycodes |
Declare a [keycodes section][xkb_keycodes] |
xkb_keymap |
Declare a [keymap block][xkb_keymap] |
xkb_layout |
Declare a legacy [layout compound section][xkb_layout] |
xkb_semantics |
Declare a legacy [semantics compound section][xkb_semantics] |
xkb_symbols |
Declare a [symbols section][xkb_symbols] |
xkb_types |
Declare a [key types section ][xkb_types] |
[include]: @ref xkb-include [interpret]: @ref interpret-statements [interpretations]: @ref interpret-statements [xkb_geometry]: @ref the-xkb_geometry-section [xkb_layout]: @ref legacy-layout-section [xkb_semantics]: @ref legacy-semantics-section
There are many built-in settings; they are explained in the following relevant sections.
These settings are case-insensitive, e.g. the following strings denote
the same key word: SETMODS, SetMods, setMods and setmods.
Each statement has a merge mode property that defines how to handle conflicts with previous statements. This property can be set explicitly by prefixing the statement with one of the merge modes presented hereinafter.
[default merge mode]: @ref merge-mode-default
Statements of the form:
// Implicit section name: use the default map
include "<PATH>"
// Explicit section name
include "<PATH>(<SECTION_NAME>)"
will merge data from another [section] of the same type, possibly located in another file. Note that the statement does not have a trailing semicolon.
If no section name is provided, the [default map] is looked up.
[default map]: @ref default-map-def
The path is usually relative to its corresponding directory in an XKB
configuration: e.g. given the configuration directory <XKB>, files of
section type xkb_symbols are looked up in <XKB>/symbols. Since 1.11,
the paths can also be absolute or use %-expansion:
@anchor keymap-include-percent-expansion
\%H\%S\%E[component]: @ref keymap-components-table
@warning Absolute paths and %-expansion are supported by libxkbcommon but not
by the legacy X11 tools.
The include keyword uses the default [merge mode]. The following keywords
can be used instead to use the corresponding explicit [merge modes][]:
augment][augment]override][override]replace][replace][merge mode]: @ref merge-mode-def [merge modes]: @ref merge-mode-def [augment]: @ref merge-mode-augment [override]: @ref merge-mode-override [replace]: @ref merge-mode-replace
Multiple files can be included using the same statement. They are separated using one of the following [merge mode] prefixes:
The following example illustrates the complete syntax:
// Default merge mode, 1 file with an implicit section name
include "<PATH>"
// Augment merge mode, 1 file with an implicit section name
augment "<PATH>(<SECTION_NAME>)"
// Absolute path and %-expansion
include "/usr/share/X11/xkb/symbols/pc"
include "%S/pc"
// Override merge mode, 2 files: a first file with an implicit section name merged
// using the augment mode with a second file with an explicit section name
override "<PATH_1>|<PATH_2>(<SECTION_NAME>)
@important Since xkbcommon 1.9.0 the included files are processed in isolation and are not affected by the parent file (e.g. defaults), except for the virtual modifiers indices.
@important Since xkbcommon 1.9.0 local merge modes are not propagated outside the section scope, i.e. an included file does not leaks its local merge modes to its parent.
The statement is processed as follow:
The current file path is searched sequentially in the
Then if no match is found, raise an error; else go to the next step.
[XKB configuration path list]: @ref xkb_context::xkb_context_include_path_append()
Let’s illustrate using the following [XKB configuration path list][]:
/home/<USER>/.config/xkb: user configuration directory
(see @ref user-configuration "")./usr/share/X11/xkb: system directory.The relevant directory structure is:
/home/<USER>/.config/xkb
symbolsesmy_own_file/usr/share/X11/xkb
symbolsesitThen the following file:
xkb_symbols {
include "it" // Exists only in system directory
include "my_own_file" // Exists only in user directory
include "es" // Exists in both user and system directory
};
is equivalent to:
xkb_symbols {
include "/usr/share/X11/xkb/symbols/it"
include "/home/<USER>/.config/xkb/symbols/my_own_file"
include "/home/<USER>/.config/xkb/symbols/es"
};
Given the following files:
symbols/A
xkb_symbols {
key <A> { [a, A, ae, AE] };
include "B(S2)"
};
symbols/B
// This section is not used (does not match)
xkb_symbols "S1" {
key <B> { [b, B] };
};
// This section will be included (match the included section name)
xkb_symbols "S2" {
key <A> { [Greek_alpha, Greek_ALPHA] };
key <B> { [Greek_beta , Greek_BETA ] };
};
the resulting section in A will be:
xkb_symbols {
// Key overridden: mix of old + new
key <A> { [Greek_alpha, Greek_ALPHA, ae, AE] };
// New key
key <B> { [Greek_beta , Greek_BETA ] };
};
Given the same file symbols/B of the previous example, the following section:
| Input | Output |
|---|---|
| ```c xkb_symbols { key { [a, A, ae, AE] }; augment "B(S2)" }; ``` | ```c xkb_symbols { // Key unchanged key { [a, A, ae, AE] }; // New key key { [Greek_beta , Greek_BETA] }; }; ``` |
| ```c xkb_symbols { key { [a, A, ae, AE] }; replace "B(S2)" }; ``` | ```c xkb_symbols { // Key replaced key { Greek_alpha, Greek_ALPHA] }; // New key key { [Greek_beta , Greek_BETA ] }; }; ``` |
| ```c xkb_symbols { key { [a, A, ae, AE] }; // Two files merged together with the merge mode // augment, then the result is merged this the // statement above using the override merge mode include "B(S1)|B(S2)" }; ``` | ```c xkb_symbols { // Key overridden: mix of old + new key { [Greek_alpha, Greek_ALPHA, ae, AE] }; // New key; "B(2)" had no effect with the // merge mode augment "|" key { [b, B] }; }; ``` |
A [keymap file] consists of a single top-level xkb_keymap
block, under which are nested the following sections:
[xkb_keycodes][xkb_types][xkb_compat][xkb_symbols]Overview of a keymap file:
xkb_keymap {
xkb_keycodes "XXX" {
// ...
}
xkb_types "XXX" {
// ...
};
xkb_compatibility "XXX" {
// ...
};
xkb_symbols "XXX" {
// ...
};
};
@since 1.9.0 All the component are optional.
@remark The XKB file format historically supported the following compound section types:
xkb_semantics: @anchor legacy-semantics-section must contain a [xkb_compat] section
and can contain a [xkb_types] section.xkb_layout: @anchor legacy-layout-section must contain [xkb_keycodes], [xkb_types]
and [xkb_symbols] sections and can contain [xkb_geometry] section.xkb_keymap: must contain [xkb_keycodes], [xkb_compat], [xkb_types] and
[xkb_symbols] sections and can contain [xkb_geometry] section.
xkb_keymap in
libxkbcommon.
A section can have various flags applied to it, separated by whitespaces:
partial alphanumeric_keys
xkb_symbols "basic" {
...
}
The possible flags are:
partial@anchor section-flag-partialdefault@anchor section-flag-defaulthidden@anchor section-flag-hiddendefault@anchor section-flag-deprecatedAdditionally, xkb_symbols may also have the following flags:
alphanumeric_keys@anchor section-flag-alphanummodifier_keys@anchor section-flag-modifierkeypad_keys@anchor section-flag-keypadfunction_keys@anchor section-flag-functionalternate_group@anchor section-flag-alt-groupIf no *_keys flags are supplied, then the symbols section is assumed to cover
a complete keyboard.
At present, except for default (see: [default map]), none of the flags affect
key processing in libxkbcommon, and only serve as metadata.
This is the simplest [section] type, and is the first one to be compiled. The purpose of this is mostly to map between the hardware/evdev scancodes and XKB [keycodes][keycode]. Each key is given a name by which it can be referred to later, e.g. in the symbols section.
Statements of the form:
<TLDE> = 49;
<AE01> = 10;
The above would let 49 and 10 be valid keycodes in the keymap, and
assign them the names TLDE and AE01 respectively. The format
<WXYZ> is always used to refer to a key by name.
The naming convention <AE01> is based on the
standard ISO/IEC 9995-1. It denotes the position of the
key in the keyboard grid. It means: the main alphanumeric section
(A), row E and column 01.
The following figure illustrates the grid on a staggered standard
US QWERTY keyboard. <AE01> corresponds to the key 1.
\ 99 \ 00 \ 01 \ 02 \ 03 \ 04 \ 05…
\ \ \ \ \ \ \
-----------------------------------------
E \ \ ^ \ 1 \ 2 \ 3 \ 4 \ 5…
------------------------------------------
D \ Tab \ Q \ W \ E \ R \ T…
-------------------------------------------
C \Caps \ A \ S \ D \ F \ G…
--------------------------------------------
B \Shift \ Z \ X \ C \ V \ B…
---------------------------------------------
A \Ctrl\GUI \Alt \Space…
----------------------------------------------
In the common case this just maps to the evdev scancodes from
/usr/include/linux/input.h, e.g. the following definitions:
#define KEY_GRAVE 41
#define KEY_1 2
correspond to the ones above. Similar definitions appear in the
X11’s xf86-input-keyboard driver. Note that in all current keymaps there’s a
constant offset of 8 (for historical reasons).
Note that contrary to xkbcommon, the X11 protocol supports keycodes
only up to 255. Therefore, when interfacing with X11, keymaps and applications
using keycodes beyond 255 should expect warnings.
If there’s a conflict, like the same name given to different keycodes, or same keycode given different names, it is resolved according to the [merge mode] which applies to the definitions.
Statements of the form:
alias <MENU> = <COMP>;
Allows to refer to a previously defined key (here <COMP>) by another
name (here <MENU>). Conflicts are handled similarly to keycode
statements.
[indicator name]: @ref indicator-name
Statements of the form:
indicator 1 = "Caps Lock";
indicator 2 = "Num Lock";
indicator 3 = "Scroll Lock";
Assigns a name to the keyboard LED (AKA [indicator]) with the given index. The LED may be referred by this name later in the [compat section][@ref the-xkb_compat-section] and by the user.
@todo virtual flag
This [section] is the second to be processed, after xkb_keycodes.
However, it is completely independent and could have been the first to
be processed (it does not refer to specific keys as specified in the
xkb_keycodes section).
This section defines [key types], which, given a key and a keyboard
state (i.e. modifier state and group), determine the [shift level] to
be used in translating the key to [keysyms]. These types are assigned
to each group in each key, in the xkb_symbols section.
Key types are called this way because, in a way, they really describe
the “type” of the key (or more correctly, a specific group of the
key). For example, an ordinary keymap will provide a type called
KEYPAD, which consists of two levels, with the second level being
chosen according to the state of the Num Lock (or Shift) modifiers.
Another example is a type called ONE_LEVEL, which is usually
assigned to keys such as Escape; these have just one level and are not
affected by the modifier state. Yet more common examples are
[TWO_LEVEL]TWO_LEVEL,
[ALPHABETIC]ALPHABETIC, etc.
Key types define a mapping between the [modifiers] and [shift levels]. Key types have four parameters:
[consumed modifiers]: @ref consumed-modifiers [shift levels]: @ref level-def
Key types are used to compute:
The following diagram presents an overview of theses computations:
@anchor xkb-types-explanation-diagram @dotfile xkb-types-explanation "Use of key types to compute shift level and consumed modifiers"
Statements of the form:
type "FOUR_LEVEL" { ... }
The above would create a new type named [FOUR_LEVEL][FOUR_LEVEL].
The body of the definition may include statements of the following
forms:
level_name[Level1] = "Base";
Mandatory for each level in the type.
Gives each level in this type a descriptive name. It isn’t used for anything.
Note: A level may be specified as Level[1-8] or just a number (can be more than 8).
modifiers = Shift+Lock+LevelThree;
Mandatory, should be specified only once.
A mask of real and virtual [modifiers]. These are the only modifiers being considered when matching the modifier state against the type. The other modifiers, whether active or not, are masked out in the calculation.
map[Shift+LevelThree] = Level4;
Should have at least as many mappings as there are levels in the type.
If the active modifiers, masked with the type’s modifiers (as stated
above), match (i.e. equal) the modifiers inside the map[] statement,
then the level in the right hand side is chosen. For example, in the
above, if in the current keyboard state the Shift and LevelThree
modifiers are active, while the Lock modifier is not, then the
keysym(s) in the 4th level of the group will be returned to the user.
map[Shift+Lock+LevelThree] = Level5;
preserve[Shift+Lock+LevelThree] = Lock;
When a key type is used for keysym translation, its modifiers are said
to be consumed in this translation. For
example, in a simple US keymap, the “G” key is assigned an ordinary
[ALPHABETIC][ALPHABETIC] key type, whose modifiers are Shift and
Lock; then for the “G” key, these two modifiers are consumed by the
translation. This information is relevant for applications which
further process the modifiers, since by then the consumed modifiers
have already “done their part” and should be masked out.
However, sometimes even if a modifier had already affected the key
translation through the type, it should not be reported as consumed,
for various reasons. In this case, a preserve[] statement can be
used to augment the map entry. The modifiers inside the square
brackets should match one of the map[] statements in the type (if
there is no matching map entry, one mapping to Level1 is implicitly
added). The right hand side should consists of modifiers from the
type’s modifiers; these modifiers are then “preserved” and not
reported as consumed.
@attention Consuming a locked modifier does not unlock it and it can be consumed again in further keysym translations.
@note Remember that @ref keysym-transformations may affect the resulting keysym when some modifiers are not consumed.
@remark preserve statements may be used to tweak keyboard shortcuts.
@remark@figure
@figcaption
Example of use of preserve to tweak Control shortcuts. Note it would
require further work in order to support other modifiers.
@endfigcaption
xkb_types {
// ...
type "TWO_LEVEL_PLUS_CONTROL" {
modifiers = Shift + Control;
map[None] = Level1;
map[Shift] = Level2;
map[Control] = Level3;
map[Control+Shift] = Level4;
// Using preserve will make Control not consumed and allow
// applications to detect keyboard shortcuts with alternative
// keysyms in levels 3 and 4 rather than the levels 1 and 2.
preserve[Control] = Control;
preserve[Control+Shift] = Control;
level_name[Level1] = "Base";
level_name[Level2] = "Shift";
level_name[Level3] = "Tweaked Control";
level_name[Level4] = "Tweaked Control + Shift";
};
};
xkb_symbols {
// ...
// The following key would produce Greek keysym on Base and Shift levels,
// but will produce the corresponding ASCII Latin keysyms when using Control.
key <AC01> {
type[Group1]="TWO_LEVEL_PLUS_CONTROL",
[Greek_alpha, Greek_ALPHA, a, A]
};
};
@endfigure
@note The convention is that Lock affect only “alphabetic” types.
For such types, Lock “cancels” Shift by default, i.e. Shift+Lock
has the same result as neither modifier. “semi-alphabetic”
types have an asymmetry: their first two levels are alphabetic while the
next are not.
The following examples compare two basic types with two levels:
[TWO_LEVEL][TWO_LEVEL] and [ALPHABETIC][ALPHABETIC].
They differ on their handling of the Lock modifier. See the
next section for an illustration
with concrete layouts.
[TWO_LEVEL]: @ref TWO_LEVEL [ALPHABETIC]: @ref ALPHABETIC
The following examples compare basic types with four levels:
[FOUR_LEVEL][FOUR_LEVEL],
[FOUR_LEVEL_SEMIALPHABETIC][FOUR_LEVEL_SEMIALPHABETIC] and
[FOUR_LEVEL_ALPHABETIC][FOUR_LEVEL_ALPHABETIC].
They differ on their handling of the Lock modifier.
See the next section
for an illustration with concrete layouts.
[FOUR_LEVEL]: @ref FOUR_LEVEL [FOUR_LEVEL_SEMIALPHABETIC]: @ref FOUR_LEVEL_SEMIALPHABETIC [FOUR_LEVEL_ALPHABETIC]: @ref FOUR_LEVEL_ALPHABETIC
This [section] is the third to be processed, after xkb_keycodes and
xkb_types.
Statements of the form:
interpret Num_Lock+Any { ... }
interpret Shift_Lock+AnyOf(Shift+Lock) { ... }
The [xkb_symbols] section (see below)
allows the keymap author to perform, among other things, the following
things for each key:
Bind a sequence of [actions], like SetMods or LockGroup, to the key.
Actions, like symbols, are specified for each level of each group
in the key separately.
Add a [virtual modifier] to the key’s virtual modifier mapping
(vmodmap).
Specify whether the key should repeat or not.
However, doing this for each key (or level) is tedious and inflexible. Interpret’s are a mechanism to apply these settings to a bunch of keys/levels at once.
@anchor interpret-mechanism Each interpret specifies a condition by which it attaches to certain levels. The condition consists of two parts:
A [keysym]. If the level has a different (or more than one)
keysym, the match fails. Leaving out the keysym is equivalent to using the
special value Any or the NoSymbol keysym, which always matches
successfully.
A [modifier] predicate. The predicate consists of:
+-separated list of modifiers or
the special value all, which denotes all the modifiers.The modifiers are matched against the key’s modifier map (modmap).
A matching operation, that is one of the following:
AnyOfOrNone – The modmap must either be empty or include at
least one of the specified modifiers.
AnyOf – The modmap must include at least one of the specified
modifiers.
Any – Alias for AnyOf(all).
NoneOf – The modmap must not include any of the specified
modifiers.
AllOf – The modmap must include all of the specified modifiers
(but may include others as well).
Exactly – The modmap must be exactly the same as the specified
modifiers.
Leaving out the predicate is equivalent to using AnyOfOrNone(all).
Leaving out just the matching condition is equivalent to using
Exactly.
An interpret may also include useModMapMods = level1; – see below.
If a [level] fulfils the conditions of several interprets, only the most specific one is used:
A specific keysym will always match before a generic NoSymbol
condition.
If the keysyms are the same, the interpret with the more specific matching operation is used. The above list is sorted from least to most specific.
If both the keysyms and the matching operations are the same (but the modifiers are different), the first interpret is used.
As described above, once an interpret “attaches” to a level, it can bind an action to that level, add one virtual modifier to the key’s vmodmap, or set the key’s repeat setting. You should note the following:
The key repeat is a property of the entire key; it is not level-specific. In order to avoid confusion, it is only inspected for the first level of the first group; the interpret’s repeat setting is ignored when applied to other levels.
If one of the above fields was set directly for a key in
xkb_symbols, the explicit setting takes precedence over the
interpret.
The body of the statement may include statements of the following forms (all of which are optional):
useModMapMods = level1;
When set to level1, the interpret will only match keysyms which are
on the first level of the first group of the keys. This can be useful
in conjunction with e.g. a virtualModifier
statement, because virtualModifier is an attribute of the key rather than a
specific level.
Note: the other possible value is any and is the default value.
See [virtual modifier map] for further information.
virtualModifier = NumLock;
Add this virtual modifier to the key’s vmodmap. The given virtual
modifier must be declared at the top level of the file with a
virtual_modifiers statement, e.g.:
virtual_modifiers NumLock;
See [virtual modifier map] for further information.
repeat = True;
Set whether the key should repeat or not. Must be a boolean value.
action = LockMods(modifiers=NumLock);
Bind this action to the matching levels. See [key actions][actions] for the list of available key actions.
Since 1.9.0, it is also possible to assign a sequence of actions, mirroring the feature used in the key statement.
action = {SetMods(modifiers=NumLock),SetGroup(group=2)};
[indicator effect]: @ref indicator-effect
Statements of the form:
indicator "Shift Lock" { ... }
This statement specifies the behavior and binding of the LED (AKA
[indicator]) with the given name (“Shift Lock” above). The name should
have been declared previously in the xkb_keycodes section (see
[LED name][indicator name] statement), and given an index there.
If it wasn’t, it is created with the next free index.
The body of the statement describes the conditions of the keyboard state which will cause the LED to be lit. It may include the following statements:
modifiers = ScrollLock;
If the given [modifiers] are in the required state (see below), the LED is lit.
whichModState = Latched+Locked;
Can be any combination of:
base, latched, locked, effectiveany (i.e. all of the above)none (i.e. none of the above)compat (legacy value, treated as effective)This will cause the respective portion of the modifier state (see
struct xkb_state) to be matched against the modifiers given in the
modifiers statement.
Here’s a simple example:
indicator "Num Lock" {
modifiers = NumLock;
whichModState = Locked;
};
Whenever the NumLock modifier is locked, the Num Lock LED will light up.
groups = All - group1;
This is a mask of group indices.
The following special values can be used in the expression:
If the given groups are in the required state (see below), the LED is lit.
whichGroupState = Effective;
Can be any combination of:
base, latched, locked, effectiveany (i.e. all of the above)none (i.e. none of the above)This will cause the respective portion of the group state (see
struct xkb_state) to be matched against the groups given in the
groups statement.
Note: the above conditions are disjunctive, i.e. if any of them are satisfied the LED is lit.
One may change the default values of the following statements:
interpret: use interpret.FIELD = VALUE;indicator: use indicator.FIELD = VALUE;ACTION_NAME.FIELD = VALUE;.
E.g. setMods.clearLocks= True;.This [section] is the fourth to be processed, after xkb_keycodes,
xkb_types and xkb_compat.
Statements of the form:
xkb_symbols "basic" {
...
}
Declare a symbols map named basic. Statements inside the curly braces only
affect the symbols map.
Statements of the form:
name[Group1] = "US/ASCII";
groupName[1] = "US/ASCII";
Gives the name “US/ASCII” to the first group of symbols. Other groups can be
named using a different group index (ex: Group2), and with a different name.
A group must be named.
group and groupName mean the same thing, and the Group in Group1 is
optional.
Statements of the form:
key <AD01> { ... };
defines the key description of the [keycode] <AD01> and is the main type
of record of the xkb_symbols section. The possible keycodes are defined in the
xkb_keycodes section.
A key description consists of:
| Feature | `::XKB_KEYMAP_FORMAT_TEXT_V1` | `::XKB_KEYMAP_FORMAT_TEXT_V2` |
|---|---|---|
| Number of overlays | **2** | **8** |
| Corresponding [keyboard controls] | [`Overlay1`][Overlay1] and [`Overlay2`][Overlay2] | [`Overlay1`][Overlay1] to [`Overlay8`][Overlay8] |
| Overlapping @anchor overlapping-overlays | **Disjoint overlays:** *no* overlap is allowed, i.e. each key can be part of *at most* one overlay. |
A key may be assigned to **any overlay without restriction**, enabling
**overlapping** overlays. There is no limitation on which overlay a given key
may belong to, and a key may be assigned to *more than one overlay*.
When *multiple* overlays are active at the same time and a key belongs to more
than one of them, the effective mapping for that key is determined by
**activation order**: the mapping defined by the **most recently activated**
overlay takes precedence over all previously activated ones, regardless of
the indices of the overlays involved.
@important This behavior differs from classic X11 overlay semantics, where
activation order carries no significance.
Example of 2 overlapping overlays@figure @figcaption Example of overlay overlap @endfigcaption Assume `` is assigned to two overlays: ```c xkb_symbols { key { [u, U], overlay1=, // numpad overlay overlay2= // edit overlay }; }; ``` Given the following activation sequence: 1. [`Overlay1`][Overlay1] is activated. `` resolves to ``. 2. [`Overlay2`][Overlay2] is subsequently activated, while [`Overlay1`][Overlay1] remains active. As [`Overlay2`][Overlay2] is now the most recently activated overlay to which `` belongs, it takes precedence: `` resolves to ``. 3. [`Overlay2`][Overlay2] is deactivated. [`Overlay1`][Overlay1] remains active and, being the most recently activated applicable overlay, resumes precedence. `` resolves once again to ``. @endfigure |
[xkb_compat]
section, but may be also set directly:
- @ref key-virtual-modifiers "Virtual modifiers"
- @ref key-repeat "Repeat"
- group wrap control (see: `xkb_layout_out_of_range_policy`)
@todo `groupsWrap`, `groupsClamp`, `groupsRedirect`
@warning Using multiple groups in symbols files is not recommended, because
some tools rely on the assumption that an xkb_symbols section only affect a
single group. It is fine with a keymap file though.
@note In what follows we assume the common use case with a single group, which benefits from a special syntax. See the section @ref key-groups "Multiple groups" for the general syntax.
[groups]: @ref layout-def
The main part of the key description is the symbols table. It maps shift levels to keysyms, e.g.:
key <AD01> { [ q, Q ] }; // Level 1 → `q`, Level 2 → `Q`
Symbols are named using the symbolic names from the
xkbcommon/xkbcommon-keysyms.h file. See the @ref keysym-syntax "keysym syntax"
for further information. A group of symbols is enclosed in brackets
and separated by commas. Each element of the symbol arrays corresponds to a
different [shift level]. In this example, the symbol (keysym) XKB_KEY_q for
level 1 and XKB_KEY_Q for level 2. These levels are configured by the
@ref key-type-setting "key type", presented in the next section.
@remark Remember that @ref keysym-transformations may affect the resulting keysym when some modifiers are not consumed.
@remark Trailing NoSymbol are dropped.
@anchor key-multiple-symbols-per-level As an extension to the XKB legacy format, libxkbcommon supports multiple key symbols and actions per level (the latter since version 1.8.0):
key <AD08> { [ {i, j} , U0132 ] }; // IJ Dutch digraph
key <AC05> { [ {g, U0303} , {G, U0303} ] }; // G̃ Guarani letter
key <AB05> { [ {U0644, U0627}, {U0644, U0622}] }; // لا لآ Arabic Lam-Alef ligatures decomposed
key <AD01> { [ {c, U2019, h} , {C, U2019, h} ] }; // C’H Breton trigraph
In this example, the keycode <AD08> produces two symbols on level 1
(XKB_KEY_i and XKB_KEY_j) and one symbol (Unicode keysym U0132 for “IJ”)
on level 2. <AD08> and <AD01> produce letters that have no precomposed
code point in Unicode. Key <AB05> avoids the need of using Compose.
@anchor keysyms-string Since 1.9.0, UTF-8-encoded strings may be used to denote a list of keysyms corresponding to the encoded Unicode code points. E.g. the previous example can be also written more intuitively as:
key <AD08> { [ "ij" , "IJ" ] }; // IJ Dutch digraph
key <AC05> { [ "g̃" , "G̃" ] }; // G̃ Guarani letter
// NOTE: We use U+200E LEFT-TO-RIGHT MARK in order to display the strings in
// in the proper order.
key <AB05> { [ "لا" , "لآ" ] }; // لا لآ Arabic Lam-Alef ligatures decomposed
key <AD01> { [ "c’h", "C’h" ] }; // C’H Breton trigraph
When no actions are explicitly given, they are automatically filled thanks to [interpretations] from the [compat section][xkb_compat]. In the following example,
key <LCTL> { [ { Control_L, ISO_Group_Shift } ] };
is equivalent to (given standard definitions from xkeyboard-config):
key <LCTL> {
symbols[1] = [ { Control_L, ISO_Group_Shift } ],
actions[1] = [ { SetMods(modifiers=Control), SetGroup(group=+1) } ]
};
When using this example with e.g. two layouts fr,us (respectively Azerty and
Qwerty layouts), typing Control + A in the first layout fr will in fact
result in Control + Q, because the actions are run sequentially: first set the
base modifiers to Control, then switch to the second layout while Control is
pressed.
@remark Given a level, keysyms and actions may have a different count. For instance, the following would achieve the same effect than the former example with only 1 keysym, but it requires to use 2 explicit actions:
key <LCTL> {
symbols[1] = [ Control_L ],
actions[1] = [ { SetMods(modifiers=Control), SetGroup(group=+1) } ]
};
@note There are some limitations with this extension:
SetMods, LatchMods, LockMods;SetGroup, LatchGroup, LockGroup.Some examples of actions combination:
SetMods + SetGroup: okSetMods + SetMods: errorSetMods + LockMods: errorSetMods + LockGroup: ok@warning Keymaps containing multiple key symbols per level are not supported
by the various X11-related tools (setxkbmap, xkbcomp, etc.).
[symbols table]: @ref key-symbols-table
Each key has a [key type] set per group. This key type is defined in the
[xkb_types] section. Its associated [shift levels] are used to
index the [symbols table] presented in the previous section.
A key type is set using the following syntax:
key <AD01> {
type[Group1] = "TWO_LEVEL", // Type
[q, Q] // Symbols
};
The name of the key type is enclosed between double quotes.
The key type may be omitted and will default to:
key.type global defaults, if set.ONE_LEVELALPHABETIC][ALPHABETIC];KEYPAD else [TWO_LEVEL][TWO_LEVEL].NoSymbol):FOUR_LEVEL_ALPHABETIC][FOUR_LEVEL_ALPHABETIC];FOUR_LEVEL_SEMIALPHABETIC][FOUR_LEVEL_SEMIALPHABETIC].FOUR_LEVEL_KEYPAD;FOUR_LEVEL][FOUR_LEVEL].@figure@figcaption Commented examples for inferred types: @endfigcaption
// 1 to 2 keysyms
key <LFSH> { [Shift_L] }; // Type: ONE_LEVEL
key <AE01> { [1, exclam] }; // Type: TWO_LEVEL
key <AD01> { [q, Q] }; // Type: ALPHABETIC
key <KP1> { [KP_End, KP_1] }; // Type: KEYPAD
// Edge case: this is consider alphabetic, although
// the lower case does not correspond to the upper case.
key <AD01> { [q, N] }; // Type: ALPHABETIC
// 3 to 4 keysyms
key <AE01> { [1, exclam, bar] }; // Type: FOUR_LEVEL
key <AE01> { [1, exclam, bar, exclamdown] }; // Type: FOUR_LEVEL
key <AD01> { [q, Q, at] }; // Type: FOUR_LEVEL_SEMIALPHABETIC
key <AD01> { [q, Q, at, Greek_OMEGA] }; // Type: FOUR_LEVEL_SEMIALPHABETIC
key <AD05> { [t, T, tslash, Tslash] }; // Type: FOUR_LEVEL_ALPHABETIC
// The inferred type is `FOUR_LEVEL`, but using `LevelThree+Lock`
// will produce `Q`, because of the keysyms transformations and
// the corresponding internal capitalization processing.
key <AE01> { [1, exclam, q, Q] }; // Type: FOUR_LEVEL
// Won’t work, because there is no heuristic for more than 4 keysyms
// It will trigger the warnings XKB-183 and XKB-516 and default to ONE_LEVEL,
// ignoring all the keysyms but the first one.
key <AD01> {[q, Q, at, any, masculine, U2642]};
// Will work as expected
key <AD01> {
type[Group1] = "EIGHT_LEVEL_SEMIALPHABETIC",
[q, Q, at, any, masculine, U2642]
};
@endfigure
@note This is usually not set explicitly but via the
[interpret mechanism] by using the
action statement in the
[xkb_compat] section.
@figure@figcaption
Example: Set the modifier action of the key <LALT> manually.
@endfigcaption
key <LALT> {
symbols[Group1]=[Alt_L],
actions[Group1]=[SetMods(modifiers=modMapMods)]
};
@endfigure
For further details see [key actions][actions].
@remark Trailing NoAction() are dropped.
Each group represents a list of symbols mapped to a keycode:
name[Group1]= "US/ASCII";
name[Group2]= "Russian";
...
key <AD01> { [ q, Q ],
[ Cyrillic_shorti, Cyrillic_SHORTI ] };
A long-form syntax can also be used:
key <AD01> {
symbols[Group1]= [ q, Q ],
symbols[Group2]= [ Cyrillic_shorti, Cyrillic_SHORTI ]
};
Groups can also be omitted, but the brackets must be present. The following statement only defines the Group3 of a mapping:
key <AD01> { [], [], [ q, Q ] };
@warning Using multiple groups in symbols files is not recommended, because
some tools rely on the assumption that an xkb_symbols section only affect a
single group. It is fine with a keymap file though.
@note This is usually not set explicitly but via the
[interpret mechanism] by using the
virtualModifier statement from the
[xkb_compat] section.
@remarks When setting a modifier action, it is required
to declare the corresponding virtual modifier using a
virtual_modifiers statement.
@figure@figcaption
Example: Set the virtual modifier of the key <LALT> to Alt.
@endfigcaption
// Declare the virtual modifier that will be used
virtual_modifiers Alt;
key <LALT> {
virtualModifiers = Alt,
[ Alt_L ]
};
@endfigure
See [virtual modifier map] for further information.
[interpret mechanism]: @ref interpret-mechanism
@note This is usually not set explicitly but via the
[interpret mechanism] by using the
repeat statement in the
[xkb_compat] section.
@figure@figcaption
Example: make the <LALT> key not repeating.
@endfigcaption
key <LALT> {
repeat = False,
[ Alt_L ]
};
@endfigure
Bind a real modifier to a key, e.g.:
// Bind the real modifier `Control` to the key `<LCTL>` and/or the first key with
// the keysym `Control_L`.
modifier_map Control { <LCTL>, Control_L };
The formats ::XKB_KEYMAP_FORMAT_TEXT_V1 (all libxkbcommon versions) and
::XKB_KEYMAP_FORMAT_TEXT_V2 (libxkbcommon < 1.14) accepts only a single
[X11 core modifier][core modifier].
Since libxkbcommon 1.14, any modifier mask expression can be used in ::XKB_KEYMAP_FORMAT_TEXT_V2:
See [real modifier map] for further information.
One may change the default values of the following statements:
key: use key.FIELD = VALUE;. E.g. key.type = "ALPHABETIC";.action: use ACTION_NAME.FIELD = VALUE;.
E.g. setMods.clearLocks= True;.[modifiers declaration and binding]: @ref modifiers-declaration-and-binding
[Modifiers] are a particularly tricky part of XKB and deserve their own section. For historical reasons they are divided in two categories:
Virtual modifiers must be declared before their first use with the
virtual_modifiers statement:
Declare a single modifier:
virtual_modifiers MyModifier;
Declare multiple modifiers using a comma-separated list:
virtual_modifiers M1, M2, M3.
Furthermore, it is possible to set the [explicit modifier encoding] with the following syntax:
Use a real modifier mask:
// Single modifier: real modifier
virtual_modifiers M1 = Mod3;
// Single modifier: using mask as a plus-separated list
virtual_modifiers M2 = Mod4+Mod5;
// Multiple modifiers
virtual_modifiers M1 = Mod3, M2 = Mod4+Mod5;
Use a numeric mask:
virtual_modifiers M1 = 0x20;
virtual_modifiers M2 = 0xC0;
virtual_modifiers M1 = 0x20, M2 = 0xC0;
Use none, an alias for 0:
virtual_modifiers M1 = none;
// Equivalent to: M1 = 0;
This can be done in the [xkb_types][xkb_types], [xkb_compat][xkb_compat] and
[xkb_symbols][xkb_symbols] sections.
[modifiers bindings]: @ref modifiers-bindings
Each key has two modifiers maps:
[real modifier map]: @ref real-modifier-map [real modifier maps]: @ref real-modifier-map [virtual modifier map]: @ref virtual-modifier-map
The [real modifier map] is set in the [xkb_symbols][xkb_symbols] section
using the modifier_map statement:
Bind directly to a keycode, e.g.:
// Bind `Mod1` to the keycode <LALT>.
modifier_map Mod1 { <LALT> };
Bind indirectly via a keysym, e.g.:
// Bind `Mod1` looking up for the keysym `Alt_L`
modifier_map Mod1 { Alt_L };
Indirect bindings require to be resolved to a single direct bindings. Given a keysym, there can be multiple keys that generate it, so the corresponding key is chosen following this order:
Bind using a comma-separated list of keycodes and keysyms:
// Bind `Mod1` diretly to keycode <LALT> and indirectly via the keysym `Alt_L`
modifier_map Mod1 { <LALT>, Alt_L };
There is also a special entry, None, that enable deleting a previous entry:
modifier_map None { <LALT> };
@note None must use the exact same target (keycode or keysym) in order to
delete the corresponding previous entry:
xkb_symbols {
key <LALT> { [Alt_L] };
modifier_map Mod1 { <LALT> };
// Does *not* delete previous entry (expected keycode, got keysym)
modifier_map None { Alt_L };
// *Does* delete previous entry (correct expected keycode)
modifier_map None { <LALT> };
};
The [virtual modifier map] can be set in 2 ways:
Directly in the [xkb_symbols][xkb_symbols] section using the
virtualModifiers key property:
xkb_symbols {
// Virtual modifiers must be declared before use
virtual_modifiers Alt;
key <LALT> {
// Explicit virtual modifier map
virtualModifiers = Alt,
...
};
};
Indirectly using [interpretations] in [xkb_compat][xkb_compat] and the
corresponding [xkb_symbols][xkb_symbols] keysyms:
xkb_compat {
// Virtual modifiers must be declared before use
virtual_modifiers Alt, Super;
interpret Alt_L {
// Bind the virtual modifier…
virtualModifier = Alt;
// … independently of the group and level (default)
useModMap = AnyLevel;
};
interpret Super_L {
// Bind the virtual modifier…
virtualModifier = Super;
// … only if the keysym is on the first level of the first group
useModMap = Level1;
};
};
xkb_symbols {
// Successful bindings
key <LALT> { [Alt_L] };
key <LALT> { [No,Symbol, Alt_L] }; // independent of group and level
key <LALT> { [], [NoSymbol, Alt_L] }; // independent of group and level
key <LWIN> { [Super_L] };
// Unsuccessful bindings
key <LWIN> { [NoSymbol, Super_L] }; // requires first level
key <LWIN> { [], [Super_L] }; // requires first group
};
[modifier encoding]: @ref modifiers-encoding
Each modifier has an associated 32 bit mask used to encode it in the keyboard state. The keyboard state represents active modifiers with the bitwise OR of the encoding of each active modifiers.
@note Display servers may use a different encoding in their protocols:
@important
Virtual modifiers require to be encoded by the user, implicitly (using the auto mode and/or the legacy mode) and/or explicitly, the combination resulting in their effective encoding.
| Modifier | Index | Encoding | ||||
|---|---|---|---|---|---|---|
| Canonical | Explicit | Implicit | Effective | |||
| (xkbcommon) | `::XKB_KEYMAP_FORMAT_TEXT_V1` | `::XKB_KEYMAP_FORMAT_TEXT_V2` | ||||
| Alt | 8 | `0x100` | `Mod1` | `Mod1` | `Mod1` | |
| Meta | 9 | `0x200` | 0 (unmapped) | `0x200` (canonical, xkbcommon value) | ||
| Super | 10 | `0x400` | 0 | `Mod4 + Mod5` | `Mod4 + Mod5` | `Mod4 + Mod5` |
| Hyper | 11 | `0x800` | `0x1000` | `0x1000` | `0x1000` | |
| Useless | 12 | `0x1000` | 0 | 0 (unmapped) | 0 (explicit mapping) | |
[explicit modifier encoding]: @ref explicit-modifier-encoding [implicit modifier encoding]: @ref implicit-modifier-encoding [effective modifier encoding]: @ref effective-modifier-encoding
@anchor canonical-modifier-def A canonical modifier have an encoding defined
by: 1 << mod_index, where mod_index is:
[canonical modifier]: @ref canonical-modifier-def
The following table summarizes the modifiers defined in
xkeyboard-config 2.44:
| Modifier | Type | Compat files | Associated keysyms |
|---|---|---|---|
Shift |
Real | compat/basic |
Shift_L, Shift_R |
| ^ | ^ | compat/iso9995 |
Shift_L, Shift_R, ISO_Level2_Latch |
Lock |
Real | compat/basic, |
Caps_Lock |
| ^ | ^ | compat/caps |
^ |
Control |
Real | compat/basic |
Control_L, Control_R |
Alt |
Virtual | compat/misc, |
Alt_L, Alt_R |
| ^ | ^ | compat/pc |
^ |
Meta |
Virtual | compat/misc |
Meta_L, Meta_R |
Super |
Virtual | compat/misc |
Super_L, Super_R |
Hyper |
Virtual | compat/misc |
Hyper_L, Hyper_R |
ScrollLock |
Virtual | compat/misc |
Scroll_Lock |
NumLock |
Virtual | compat/basic, |
Num_Lock, |
| ^ | ^ | compat/level5 |
(ISO_Level5_Lock) |
LevelThree |
Virtual | compat/iso9995 |
ISO_Level3_Shift, ISO_Level3_Latch, ISO_Level3_Lock |
LevelFive |
Virtual | compat/level5 |
ISO_Level5_Shift, ISO_Level5_Latch, ISO_Level5_Lock |
Kana_Lock |
Virtual | compat/japan |
Kana_Lock |
Square |
Virtual | compat/olpc |
KP_Home |
Cross |
Virtual | compat/olpc |
KP_Next |
Circle |
Virtual | compat/olpc |
KP_End |
Triangle |
Virtual | compat/olpc |
KP_Prior |
@note Any field that accept virtual modifier names is a virtual modifier mask, denoting virtual modifiers indices. These indices are implementation-specific and should not be leaked. Therefore any numeric value used for these fields should be interpreted equally as a virtual modifier mask, and is thus implementation-specific.
@important In order to preserve [modifier encoding] portability, XKB implementations are recommended to avoid numeric modifier masks and to use virtual modifiers names whenever possible when serializing the keymap. This avoids leaking the indices of the modifiers.
@attention This section is not part of the keymap text format specification and presents libxkbcommon’s implementation details that may change, solely for the purpose of informing other XKB implementation. Users should not rely on this!
Both X11 xkbcomp and libxkbcommon currently implement modifiers indices as follow:
Shift | 0 |
| Lock | 1 |
| Control | 2 |
| Mod1 | 3 |
| Mod2 | 4 |
| Mod3 | 5 |
| Mod4 | 6 |
| Mod5 | 7 |@note It suffices to declare all virtual modifiers in [xkb_types] (or if empty, whatever non-empty section afterwards, in the order specified above) in their ascending indices order to use virtual modifiers indices compatible with libxkbcommon.
We will use the example of the real modifier Shift and the virtual
modifier LevelThree in xkeyboard-config.
In order to define and use a modifier, one must:
Define its behavior and [keysym] binding in the
[xkb_compat] section:
// Declare virtual modifiers. Shift being real modifier,
// we do not need to add it here.
virtual_modifiers LevelThree;
// Set defaults. They are overridden if set directly in the xkb_symbols.
interpret.repeat= False; // only applied on first level
setMods.clearLocks= True;
latchMods.clearLocks= True;
latchMods.latchToLock= True;
// Default statement for real modifiers: any key bound to a real
// modifier via modifier_map will set this modifier at all its
// levels.
// Here only to illustrate: do not add it!
interpret Any + Any {
action= SetMods(modifiers=modMapMods);
};
// Shift being real modifier, we do not need a corresponding
// interpret statement because the previous one suffices.
// Let’s associate LevelThree to the keysym ISO_Level3_Shift
// First, match the keys and their levels with the
// ISO_Level3_Shift keysym and with any real modifier
// (Any = AnyOf(all)) in its modmap.
interpret ISO_Level3_Shift+Any {
// Only match the first level of the first group
useModMapMods= level1;
// Add the virtual modifier to the key’s vmodmap
virtualModifier= LevelThree;
// Activate the LevelThree modifier (depressed mode)
action= SetMods(modifiers=LevelThree);
};
// Then for keys and their levels with the
// ISO_Level3_Shift keysym but with either no real modifier
// in its modmap or a level higher than 1.
// Indeed:
// • In case the level is higher than 1 there is no match
// in the previous statement.
// • The condition is equivalent to
// ISO_Level3_Shift+AnyOfOrNone(all), but since
// the previous statement ISO_Level3_Shift+Any is more
// specific, it will be matched before this one.
interpret ISO_Level3_Shift {
// Activate the LevelThree modifier (depressed mode)
action= SetMods(modifiers=LevelThree);
};
Define [key types] that use it in the
[xkb_types] section:
// Declare virtual modifiers. Shift being real modifier,
// we do not need to add it here.
virtual_modifiers LevelThree;
type "FOUR_LEVEL" {
// Key type modifier mask: all the modifiers used in the key type
modifiers = Shift + LevelThree;
map[None] = Level1;
map[Shift] = Level2;
map[LevelThree] = Level3;
map[Shift+LevelThree] = Level4;
level_name[Level1] = "Base";
level_name[Level2] = "Shift";
level_name[Level3] = "AltGr";
level_name[Level4] = "Shift AltGr";
};
Bind it to a [keycode] in the
[xkb_symbols] section:
xkb_compat section hereinabove.modifier_map.Note: Only one key binding to real modifier is required. The corresponding keysym must then be on the first level of the first Group.
Note: One can optionally bind directly a virtual modifier to a
key using virtualmodifiers instead of doing it in the
xkb_compat section. But the recommended way is to use the
xkb_compat section.
// Shift: defined in pc symbols
key <LFSH> {[ Shift_L ]};
key <RTSH> {[ Shift_R ]};
modifier_map Shift { Shift_L, Shift_R };
// The previous will resolve to:
// modifier_map Shift { <LFSH>, <RTSH> };
// Thus the real modifier Shift is added to the modmap of
// <LFSH> and <RTSH>.
// The “Any + Any” interpret statement matches <LFSH> and <RTSH>,
// therefore these keys set the Shift modifier.
// LevelThree: defined in pc symbols
// With the following 2 lines:
// 1. The modifier keysym is on the first level of the first group.
// 2. The real modifier Mod5 is bound to <LVL3>,
// i.e. Mod5 is added to its modmap.
// 3. It matches the interpret statement “ISO_Level3_Shift+Any”,
// which adds the LevelThree modifier to the vmodmap of <LVL3>.
// 4. The mapping of LevelThree to real modifiers is the union
// of modmaps with corresponding vmodmaps containing
// LevelThree. In our case there is only one: therefore
// LevelThree maps to Mod5.
key <LVL3> {[ ISO_Level3_Shift ]};
modifier_map Mod5 { <LVL3> };
// LevelThree: defined in level3 symbols
// Not bound to a real modifier, so interpret statement
// “ISO_Level3_Shift” applies.
key <RALT> {[ISO_Level3_Shift], type[group1]="ONE_LEVEL" };
// Note: we could have the following line, but it is not necessary
// because we have the mappings of <LVL3>.
// modifier_map Mod5 { <RALT> };
// Warning: if we had the for example the following line, the
// mapping of LevelThree to real modifiers would be “Mod1+Mod5”.
// modifier_map Mod1 { <RALT> };
// Alternative definitions, without using interpret statements
virtual_modifiers LevelThree;
key <LVL3> { virtualmodifiers=LevelThree
, repeats=False
, symbols[Group1] = [ISO_Level3_Shift]
, actions[Group1] = [SetMods(modifiers=LevelThree)] };
modifier_map Mod5 { <LVL3> };
key <RALT> { repeat=False
, symbols[Group1] = [ISO_Level3_Shift]
, actions[Group1] = [SetMods(modifiers=LevelThree)]
, type[group1]="ONE_LEVEL" };
// FOUR_LEVEL key type example from latin symbols
key <AB05> {[b, B, leftdoublequotemark, leftsinglequotemark]};
The following table provide an overview of the available actions:
| Category | Action name | Alias | Description |
|---|---|---|---|
| [Ineffectual action] | [NoAction][NoAction] |
Default action: implicitly do nothing | |
| ^ | [VoidAction][VoidAction] |
Explicitly do nothing | |
| [Modifier action] | [SetMods][SetMods] |
Modifies the [depressed] modifiers | |
| ^ | [LatchMods][Latchmods] |
Modifies the [latched] modifiers | |
| ^ | [LockMods][LockMods] |
Modifies the [locked] modifiers | |
| [Group action] | [SetGroup][SetGroup] |
Modifies the base group | |
| ^ | [LatchGroup][LatchGroup] |
Modifies the latched group | |
| ^ | [LockGroup][LockGroup] |
Modifies the locked group | |
| [Keyboard controls action] | [SetControls][SetControls] |
Set the standard XKB controls | |
| ^ | [LockControls][LockControls] |
Lock the standard XKB controls | |
| [Keyboard emulation action] | [RedirectKey][redirectkey] |
Redirect |
Emulate pressing a key with a different key code |
| [Legacy action] | MovePointer |
MovePtr |
Move the mouse pointer |
| ^ | PointerButton |
PtrBtn |
Simulate a mouse button press |
| ^ | LockPointerButton |
LockPtrBtn |
Simulate a mouse button press, locked until the action’s key is pressed again. |
| ^ | SetPointerDefault |
SetPtrDflt |
Set the default select button (???) |
| ^ | [TerminateServer][TerminateServer] |
Terminate |
Shut down the X server |
| ^ | SwitchScreen |
Switch virtual X screen | |
| ^ | [Private][Private] |
Raw encoding of an action | |
| [Unsupported legacy action] | ISOLock |
Convert ordinary modifier key actions into lock actions while this action is active | |
| ^ | DeviceButton |
DevBtn |
Emulate an event from an arbitrary input device such as a joystick |
| ^ | LockDeviceButton |
LockDevBtn |
Emulate an event from an arbitrary input device such as a joystick |
| ^ | DeviceValuator |
DevVal |
TODO |
| ^ | MessageAction |
Message |
Generate an arbitrary special-purpose XKB event |
Common syntax:
true, yes, onfalse, no, off[ineffectual action]: @ref ineffectual-actions [NoAction]: @ref no-action [VoidAction]: @ref void-action
[modifier action]: @ref modifiers-actions [modifier actions]: @ref modifiers-actions [SetMods]: @ref set-mods-action [LatchMods]: @ref latch-mods-action [LockMods]: @ref lock-mods-action
There are 3 modifiers actions:
| Name | Aliases | Data type | Default value | Description |
|---|---|---|---|---|
| `modifiers` | `mods` | Modifier mask | `none` (0) | The list of modifiers to modify, separated by `+`, or the special value `modMapMods`. The latter means the parameter value has to be read from the `vmodmap` attribute of the key. |
| `clearLocks` | boolean | `false` | See its use [hereinafter](@ref set-modifier-action-effects) | |
| `unlockOnPress` | boolean | `false` | Control whether [locked] modifiers are unlocked on key press or release (default). See [hereinafter](@ref set-modifier-action-effects) for further details. @note Available since 1.11, only with `::XKB_KEYMAP_FORMAT_TEXT_V2`. |
| Name | Aliases | Data type | Default value | Description |
|---|---|---|---|---|
| `modifiers` | `mods` | Modifier mask | `none` (0) | see [`SetMods`][SetMods]. |
| `clearLocks` | boolean | `false` | See its use [hereinafter](@ref latch-modifier-action-effects) | |
| `latchToLock` | boolean | `false` | See its use [hereinafter](@ref latch-modifier-action-effects) | |
| `latchOnPress` | boolean | `false` | Control whether [latched] modifiers are latched on key press or release (default). See [hereinafter](@ref latch-modifier-action-effects) for further details. @note Available since 1.11, only with `::XKB_KEYMAP_FORMAT_TEXT_V2`. | |
| `unlockOnPress` | boolean | `false` | Control whether [locked] modifiers are unlocked on key press or release (default). See [hereinafter](@ref latch-modifier-action-effects) for further details. @note It is *implied* if both `latchOnPress=true` and `clearLocks=true`. @note Available since 1.11, only with `::XKB_KEYMAP_FORMAT_TEXT_V2`. |
| Name | Aliases | Data type | Default value | Description |
|---|---|---|---|---|
| `modifiers` | `mods` | Modifier mask | `none` (0) | see [`SetMods`][SetMods] |
| `affect` | enumeration: - `lock` - `unlock` - `both` - `neither` | `both` | - `lock`: the action only locks the modifier, but cannot unlock it. - `unlock`: the action only unlocks modifier, but cannot lock it. - `both`: the first key press locks the modifier and the second key press releases the modifier. - `neither`: do not lock nor unlock, i.e. do nothing. | |
| `unlockOnPress` | boolean | `false` | Control whether [locked] modifiers are unlocked on key press or release. See [hereinafter](@ref lock-modifier-action-effects) for further details. @note Available since 1.11, only with `::XKB_KEYMAP_FORMAT_TEXT_V2`. |
@todo highlight that there is reference counting for the modifiers, e.g. to manage multiple physical keys for the same modifier.
These actions perform different tasks on key press and on key release:
| Action | On key press | On key release |
|---|---|---|
| `SetMods` @anchor latch-modifier-action-effects | - If `clearLocks` and `unlockOnPress` are true, unlock the target modifiers. - Adds modifiers to [depressed] modifiers that were not unlocked. | - Removes modifiers added on press from [depressed] modifiers, provided that no other key which affects the same modifiers is logically down. - If `clearLocks` is true, `unlockOnPress` is false and no other key were operated simultaneously with this key, then the modifiers will be removed as well from the [locked] modifiers. |
| `LatchMods` @anchor set-modifier-action-effects | - If `unLockOnPress` and `clearLocks` are true and target modifiers were locked, then unlocks them and clear the action. - Otherwise if `latchOnPress` is true, then adds modifiers to the [latched] modifiers. - Otherwise adds modifiers to [depressed] modifiers. | - If `latchOnPress` is false, then: - Removes modifiers from [depressed] modifiers. - If no keys were operated simultaneously with the latching modifier key: - If `clearLocks` is true and `unLockOnPress` is false and target modifiers were locked, then unlock then stop here and clear the action. - Otherwise add modifiers to [latched] modifiers. - If `latchToLock` is true and if the target modifiers are latched, then unlatch them and [lock][locked] them. - Latch target modifiers that were not used by `clearLocks` and `latchToLock`. - Otherwise unlatch the target modifiers and clear the action. |
| `LockMods` @anchor lock-modifier-action-effects | - If `unlockOnPress` is true and some of the target modifiers were [locked] before the key press, then unlock them if `noUnlock` false. - Otherwise: - add target modifiers to [depressed] modifiers; - if `noLock` is false, add target modifiers to the [locked] modifiers. | - If `unlockOnPress` is true and triggered unlocking on key press, do nothing. - Otherwise: - remove modifiers from the [depressed] modifiers, if no other key that affect the same modifiers is down; - if `noUnlock` is false and if any target modifiers was locked before the key press, *[unlock][locked]* them. |
[group action]: @ref group-actions [group actions]: @ref group-actions [SetGroup]: @ref set-group-action [LatchGroup]: @ref latch-group-action [LockGroup]: @ref lock-group-action
There are 3 group actions:
| Name | Data type | Default value | Description |
|---|---|---|---|
| `group` |
Group index:
- 1-based numbering
- Named constants:
|
0 | Target group or group delta |
| `clearLocks` | boolean | `false` | See its use [hereinafter](@ref set-group-action-effects) |
| Name | Data type | Default value | Description |
|---|---|---|---|
| `group` | Group index (see [`SetGroup`][SetGroup]) | 0 | Target group or group delta |
| `clearLocks` | boolean | `false` | See its use [hereinafter](@ref latch-group-action-effects) |
| `latchToLock` | boolean | `false` | See its use [hereinafter](@ref latch-group-action-effects) |
| Name | Data type | Default value | Description |
|---|---|---|---|
| `group` | Group index (see [`SetGroup`][SetGroup]) | 0 | Target group or group delta |
| `lockOnRelease` @anchor lockOnRelease | boolean | false | Control whether to trigger the group change on key press (default) or release. See further details [hereinafter](@ref lock-group-action-effects) @note Available since 1.11, only with `::XKB_KEYMAP_FORMAT_TEXT_V2`. |
| Action | On key press | On key release |
|---|---|---|
| `SetGroup` @anchor set-group-action-effects | - If the `group` parameter is *absolute*, key press events sets the *base* keyboard group to `group`. - Otherwise, it adds `group` to the *base* keyboard group. In either case, the resulting *effective* keyboard group is brought back into range depending on the value of the `GroupsWrap` control for the keyboard. See `xkb_layout_out_of_range_policy` for further details. | If *no* keys were operated simultaneously with this key and the `clearLocks` parameter is set, key release also sets the *locked* keyboard group to `Group1`. |
| `LatchGroup` @anchor latch-group-action-effects | Same as `SetGroup`. | Same as `SetGroup`. If no keys were operated simultaneously with the latching group key and the `clearLocks` parameter was not set or had no effect, key release has the following additional effects: - If `latchToLock` parameter is set and the *latched* keyboard group is not the first group, the key release adds the *delta* applied by the corresponding key press to the locked keyboard group and subtracts it from the latched keyboard group. The *locked* and *effective* keyboard group are brought back into range according to the value of the global `GroupsWrap` control for the keyboard. See `xkb_layout_out_of_range_policy` for further details. - Otherwise, key release adds the key press *delta* to the latched keyboard group. |
| `LockGroup` @anchor lock-group-action-effects | - If `lockOnRelease` is set, then key press has no effect. - Otherwise: - if the `group` is absolute, key press sets the *locked* keyboard group to `group`; - otherwise, key press adds `group` to the *locked* keyboard group. In either case, the resulting *locked* and *effective* group is brought back into range depending on the value of the `GroupsWrap` control for the keyboard. See `xkb_layout_out_of_range_policy` for further details. |
- If `lockOnRelease` is not set, then key release has no effect.
- Otherwise, if any other key was *pressed* after the locking key, then
key release has no effect.
This enables e.g. using `Alt+Shift` combination in any order.- `Shift` down, `Alt` down, `Alt` up, `Shift` up - `Shift` down, `Alt` down, `Shift` up, `Alt` up - `Alt` down, `Shift` down, `Shift` up, `Alt` up - `Alt` down, `Shift` down, `Alt` up, `Shift` up This would not be possible if locking was cancelled by key *release* too. |
[Keyboard controls action]: @ref kbd-control-actions [SetControls]: @ref set-controls-action [LockControls]: @ref lock-controls-action
| Name | Alias | Data type | Default value | Description |
|---|---|---|---|---|
| `controls` | `ctrls` | Mask of the following enumeration: - `RepeatKeys` - `Repeat` - `AutoRepeat` - `SlowKeys` - `BounceKeys` - `StickyKeys` - `MouseKeys` - `MouseKeysAccel` - `AccessXKeys` - `AccessXTimeout` - `AccessXFeedback` - `AudibleBell` - `IgnoreGroupLock` - [`Overlay1`](@ref XKB_KEYBOARD_CONTROL_OVERLAY1) - [`Overlay2`](@ref XKB_KEYBOARD_CONTROL_OVERLAY2) - Requires `::XKB_KEYMAP_FORMAT_TEXT_V2` and version 1.14+ - [`Overlay3`](@ref XKB_KEYBOARD_CONTROL_OVERLAY3) - [`Overlay4`](@ref XKB_KEYBOARD_CONTROL_OVERLAY4) - [`Overlay5`](@ref XKB_KEYBOARD_CONTROL_OVERLAY5) - [`Overlay6`](@ref XKB_KEYBOARD_CONTROL_OVERLAY6) - [`Overlay7`](@ref XKB_KEYBOARD_CONTROL_OVERLAY7) - [`Overlay8`](@ref XKB_KEYBOARD_CONTROL_OVERLAY8) Plus 2 special values: - `all` - `none` | 0 | Standard XKB *boolean* controls |
| Name | Alias | Data type | Default value | Description |
|---|---|---|---|---|
| `controls` | `ctrls` | Mask (see [`SetControls`][SetControls]) | 0 | Standard XKB *boolean* controls |
| `affect` | enumeration: - `lock` - `unlock` - `both` - `neither` | `both` | - `lock`: the action only locks the controls, but cannot unlock them. - `unlock`: the action only unlocks controls, but cannot lock them. - `both`: the first key press locks the controls and the second key press releases the controls. - `neither`: do not lock nor unlock, i.e. do nothing. |
@warning Only a subset of the original XKB controls are effectual.
See xkb_keyboard_control_flags for further details.
| Action | On key press | On key release |
|---|---|---|
| `SetControls` @anchor set-controls-action-effects | Enable any boolean controls that are specified in `controls` and not already enabled at the time of the key press. | Disable any controls that were enabled by the corresponding key press. |
| `LockControls` @anchor lock-controls-action-effects | If `noLock` is false, locks and enables any boolean controls that are specified in `controls` and not already locked at the time of the key press. | If `noUnlock` is False, key release unlocks and disables any controls that are specified in `controls` and *were* enabled at the time of the corresponding key press. |
[Keyboard emulation action]: @ref kbd-emulation-actions [redirectkey]: @ref redirect-key-action
RedirectKey emulates pressing a key with a different key code.
RedirectKey normally redirects to another key on the same device as the key
or button which caused the event, else on the core keyboard device.
| Name | Aliases | Data type | Default value | Description |
|---|---|---|---|---|
| `key` | `keycode`, `kc` | keycode or `auto`. @anchor redirect-key-auto `auto` is a special value that resolves to the keycode where the action is located, e.g.: ```c // Original: implict parameter key { [RedirectKey(…) ] }; // Original: explicit parameter key { [RedirectKey(keycode=auto, …) ] }; // Resolved key { [RedirectKey(keycode=, …) ] }; ``` | `auto` @since 1.0.0: invalid keycode @since 1.14.0: `auto` | Target keycode to emulate |
| `clearmodifiers` | `clearmods` | modifier mask | `none` (0) | Modifiers to clear |
| `modifiers` | `mods` | modifier mask | `none` (0) | Modifiers to add |
| On key *press* | On key *release* |
|---|---|
| Key press causes a key press event for the key specified by the `key` parameter instead of for the actual key. The state reported in this event reports of the current *effective* modifiers changed as follow: - Modifiers in the `clearmodifiers` parameter are cleared. - Modifiers in the `modifiers` parameter are set. | Key release causes a key release event for the key specified by the `key` parameter; the state field for this event consists of the *effective* modifiers at the time of the release, changed as described on the key press. |
[legacy action]: @ref legacy-x11-actions
@attention The following legacy actions are kept for compatibility only: they are parsed
and validated but have no effect. This allows to use keymaps defined in
xkeyboard-config for both X11 and Wayland.
[TerminateServer]: @ref terminate-server-action
[Private]: @ref private-action
Raw encoding of an action. Aimed to support arbitrary action unknown to the XKB compiler.
@warning This assumes that the corresponding action’s C struct is laid out in
memory exactly as described in the XKB specification and libraries. However,
libxkbcommon have changed these structs in various ways, so this assumption is
no longer true and the actions defined in the XKB protocol are unsupported.
| Name | Data type | Default value | Description |
|---|---|---|---|
| `type` | integer | 0 | Action type, as encoded in the XKB protocol |
| `data` | byte array or a string of *exactly 7 bytes* | "0000000" | Raw byte encoding of the action following the XKB protocol |
Examples:
Private(type=123, data="abcdefg");Private(type=123, data[1]=0, data[2]=100, data[3]=12);[unsupported legacy action]: @ref unsupported-legacy-x11-actions
@attention The following legacy actions are unsupported: they are parsed and but not validated and are then completely ignored.
@todo ISOLock
@todo ActionMessage
This section aims to describe the physical layout of a keyboard and its main
use case is to produce a picture of the keyboard via e.g. the xkbprint program.
@warning libxkbcommon does not support this section: while it can parse the syntax, it does not interpret it; the section is simply dropped so there is no API to query it and the keymap serialization does not contain it.
@sa @ref geometry-support "Compatibility with X11".