User:John3-16/Compose key
![]() Updated page is now in main wiki: Compose key. This page version is no longer updated. (Discuss)Make sure no other pages link here and check the page's history before deleting. |
A compose key may be assigned to quickly produce certain characters from a keyboard. These could include a letter with an accent such as é; a letter with a diacritic such as ç; or various symbols and emojis such as ≥, ☺, etc. They could be composed within various applications, including various text editors, shells or certain other packages. For example, if one were to choose the <AltGr> key as the compose key on a given installation, depending on the configuration method chosen, one may obtain the character "é" by pressing the following three characters one after another:
<AltGr> + <'> + <e> = é
Other examples may include:
<AltGr> + <,> + <c> = ç <AltGr> + <c> + <c> = č <AltGr> + <1> + <2> = ½ <AltGr> + <=> + <E> = € <AltGr> + <-> + <L> = £
Note also that you may need to "hold" the <Shift> key with the next character in order to produce some characters, depending on your keyboard layout. For example, on some keyboards where the colon appears over the semi-colon:
Hold<Shift>+<;> = :
Therefore, consider the following example:
<AltGr> + <:> + <)> = ☺
Depending on your layout, since additionally the left bracket ')' on some layouts is created by shifting the "zero" key, one may need to do as follows:
<AltGr> + Hold<Shift>+<;> + Hold<Shift>+<0> = ☺
Note that under some environments, one may obtain an umlaut/diaeresis (¨) by employing the colon symbol (:). Alternatively, depending on your configuration, you may need to obtain the umlaut by using the double-quotes ("). For example:
<AltGr> + <"> + <a> = ä
Consider additionally that, depending on the keyboard configuration, double-quotes are sometimes composed as Hold<shift>+<'>. Therefore, depending on the keyboard configured, one might need to obtain that "ä" as follows:
<AltGr> + Hold<Shift>+<'> + <a> = ä
Consider a listing of combinations under Xorg.
Assign the compose key

Decide what compose key you will choose. Then, you may need to refer to it in the instructions below by its technical term listed in italics, as follows:-
- <LWIN> or <Left Windows> key a.k.a. the 'Windows' or 'Logo' key on the left: lwin
- <RWIN> or <Right Windows> key (it exists on some keyboards and is not to be confused with the 'Windows' key on the left): rwin
- <AltGr> key a.k.a. the <Alt> key on the right: ralt
- <Alt> key on the left: lalt
- <Menu> key a.k.a. the 'Application' key, typically used to open context menus, as when right-clicking from a mouse, displaying a right-click menu and pointer, often found between the <Right Alt> and <Right Control> keys —not to be confused with the the <LWIN>/'Logo'/<Left Windows> key: menu
- <Caps Lock> key: caps
- <Pause> key: paus
- <Print Scrn> key: prsc
- <Scroll Lock> key: sclk
- <Right Control> key: rctrl
- <Left Control> key: lctrl
In desktop environments
If the desktop environment was installed via setup-desktop
, one should first consider assigning the compose key through one of the desktop's "Settings" modules and then, specifically, seeking those relating to "Keyboard" or, alternative, an "autostart" module:-
Gnome
Activities (on toolbar) \ type the word Settings \ Settings icon \ Keyboard \ enable Compose Key \ select the Compose Key
XFCE
Applications \ Settings \ Settings Editor \ Channel keyboard-layout \ XkbOptions \ Compose \ type compose:ralt
or otherwise for your preferred compose key
Mate
System \ Control Centre \ Keyboard \ Layout \ Options \ Position of Compose Key click on triangle \ Select your compose key
Sway
Check your input settings first:
$ swaymsg -t get_inputs
If your preferred compose key is not stated, then open your configuration file (~/.config/sway/config
) with your preferred text editor, and in order to specify that the <AltGr> key/'right alt' key is your compose key, consider entering the following xkb_options
line inside the input "type:keyboard"
stanza, as follows (without the [...]
):
input "type:keyboard" { [...] xkb_options compose:ralt }
LXQt
LXQt under XOrg:
You may require installing setxkbmap first; then, consider using the autostart instruction:
Preferences \ LXQt Settings \ Session Settings \ Autostart \ Add
Where prompted under that module, add a line specifying your chosen compose key setting. For example:
/usr/bin/setxkbmap -option compose:ralt &
Under Wayland:
Consider applying the guide below, regarding window sessions for under Wayland in general.
If the Plasma desktop environment is installed:
Plasma
System Settings \ Hardware \ Input Devices \ Keyboard \ Advanced \ tick Configure keyboard options \ tick Position of Compose key \ tick selection
The desktop environment's man pages may give more detailed configurations for the compose key. The following section may also be additionally be useful e.g. where one drops into a tty environment or when switching into a different window manager/compositor than those listed above.
Without set desktop environments
From the following examples, consider the model where the <AltGr> key (ralt key) could be assigned for the user only. If a different key is preferred, consider substituting with the key's technical term listed above.
Under XOrg
There are various methods. Consider installing setxkbmap.
$ doas apk add setxkbmap
For XOrg window sessions:
In your window manager's autostart file, consider entering the following:
/usr/bin/setxkbmap -option compose:ralt &
If there is no autostart file, consider adding that instruction into ~/.xinitrc
before the last line(s) that is/are being used to launch any window session.
That instruction can also be entered from a shell in order to assign the compose key so as to be in effect only during the login session.
For tty/windowless sessions:
The same setxkbmap instruction could be used at the tty. To autostart this setting for future sessions:-
- Consider adding it to a session autostart file; or
- If there is no autostart file, consider adding it, as proposed directly above for XOrg window sessions, to
~/.xinitrc
; or - If there is no
~/.xinitrc
, consider executing the following:
Create the file (adding the line to
~/.profile
instead may be poor practice);touch ~/.xinitrc
Make
~/.xinitrc
executable and read-and-write only by the user:doas chmod 700 ~/.xinitrc
Then, add lines to instruct the file to be read with the default
sh
interpreter; plus the setxkbmap command as indicated above:#!/bin/sh /usr/bin/setxkbmap -option compose:ralt &
Further documentation:
man xkeyboard-config
Under Wayland
Consider various approaches, including:-
Option with ~/.profile
Open the file (creating the file first if it doesn't exist), and consider adding:
export XKB_DEFAULT_OPTIONS="compose:ralt"
A list of compose sequences available depend on your keyboard locale.
Further references for this X Keyboard Extension (XKB_DEFAULT_OPTIONS) include:-
Option using gsettings
Install gsettings-desktop-schemas, if not installed:
$ doas apk install gsettings-desktop-schemas
Next:
$ gsettings set org.gnome.desktop.input-sources xkb-options "[\'compose:ralt\']"