User:John3-16/Compose key
A compose key, also known as a "multi key", can be assigned to quickly produce certain characters from a keyboard, such as a letter with an accent, such as é, or with a diacritic, or symbols and emojis such as ☺, etc, to be entered into the currently opened application, such as in a text editor, a shell, or inside various other packages. For example, if one were to assign the <AltGr> key as the compose key in one's 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> + <=> + <E> = € <AltGr> + <-> + <L> = £ <AltGr> + <a> + <e> = æ ` ``
Note also that you may need to "hold" the <Shift> key with the next character in order to produce some characters, depending on your chosen 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 called 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
[TODO:
- Elaborate on alternative methods.
- Document assigning the compose key for all users.
Contributors welcome.]
Decide what compose key you will choose. Then, you may need to refer to it in the instructions below by its technical term, which may be listed here 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 'Logo'/'lwin' 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 is installed via `setup-desktop`, one could seek to assign the compose key through one of the desktop's 'Settings' modules and then, specifically, those relating to 'Keyboard' or similar:
Activities (on toolbar) \ type the word "Settings" \ Settings icon \ Keyboard \ enable "Compose Key" \ select the Compose Key
'gnome', 'xfce', 'mate', 'sway', 'lxqt' or 'none')
Applications \ Settings \ Settings Editor \ Channel "keyboard-layout" \ XkbOptions \ Compose \ type `compose:ralt` or otherwise for your preferred compose key
System \ Control Centre \ Keyboard \ Layout \ Options \ Position of Compose Key clcik on triangle \ Select your compose key
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
- Under XOrg: Consider following the passage below for 'XOrg window sessions', installing setxkbmap first, and then applying the autostart instruction by going to:
Preferences \ LXQt Settings \ Session Settings \ Autostart \ Add
Add a line with your chosen compose key setting, such as:
/usr/bin/setxkbmap -option compose:ralt &
- Under Wayland: Consider applying the guide below, Under Wayland
If Plasma desktop environment is installed:
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 austostart file, consider adding that instruction in `~/.xinitrc` before the last line(s) 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 the setxkbmap instruction above.
Further documentation: man xkeyboard-config
Under Wayland
Consider [various approaches](https://superuser.com/questions/1160777/make-special-characters-available-on-us-keyboard-an-wayland); Sway's method suggested above should be considered for that compositor.
- Option with `~/.profile`: Open the file (creating the file first if it doesn't exist), and consider adding:
``` export XKB_DEFAULT_OPTIONS="compose:ralt" ```
References for this X Keyboard Extension (XKB) include:-
- Option using gsettings:-
Install gsettings-desktop-schemas, if not currently installed:
$ doas apk install gsettings-desktop-schemas-
Next:
$ gsettings set org.gnome.desktop.input-sources xkb-options "[\'compose:ralt\']"