secluded/content/posts/typing-international-charac...

70 lines
5.5 KiB
Markdown
Raw Normal View History

2021-01-11 17:34:38 +00:00
---
title: "Typing International Characters"
description: "Setting up your keyboard so you can type international characters such as ß, ñ, and ü in addition to a myriad of others (™, ©, ¢, €, ∵, ∞, §, ¶, etc.)"
date: 2020-04-08T13:21:39-04:00
tags:
- Keyboard
- Typing
- Writing
- International
- Typography
categories:
- Technology
cover: /assets/pngs/keyboard.png
toc: true
---
My first computer was an [Acer C710 Chromebook](https://www.cnet.com/products/acer-c710-2055-chromebook/specs/). There were a *lot* of problems with it but one thing I always appreciated were its dead keys. Until a few days ago, I had *completely* forgotten what the feature was called. Once I figured it out, however, I was able to do some digging and find the answer fairly quickly.
## Dead keys
Dead keys[^1] are actually a type of modifier, like `Ctrl` or `Shift`. They allow people to type accented characters that don't appear on their keyboard. For example, I have a US keyboard and there is no enye (the diactric[^2] mark over the ñ) as can be found on Spanish and Latin American layouts.
I'm not exactly sure why but dead keys don't have to be held down when you want to use them but they don't; simply strike the dead key then the character you intend to modify and the resulting accented character will be rendered properly.
Dead keys allow writers to use far more characters that just the accented ones found in various alphabets. Indeed, one can type a *very* wide variety of symbols:
```
™ © ® § ¶ ∵ € ¢ ¥ ⅞ x³ ∞ ¬ ÷ ± × ≠ ♪ ♬ ♭ ♮ ♯ → ⇒ ☭ ㉔ ⓐ ß æ ø Œ
```
The full list of all possible combinations (on Linux) can be found in [the documentation from David Monniaux](https://cgit.freedesktop.org/xorg/lib/libX11/plain/nls/en_US.UTF-8/Compose.pre). For a shorter but easier-to-read list, refer to the [GtkComposeTable from Ubuntu](https://help.ubuntu.com/community/GtkComposeTable).
## Compose key
If you write code *at all*, enabling dead keys alone would be an absolute *nightmare*. To get double quotes, you would have type `"` then `Space` every single time. The same goes for `'`, `:`, `;`, `~`, etc. The compose key[^3] makes this *much* less of an issue. When struck, it indicates that the next few keys (2 or more) are to function as dead keys. With this enabled, you can write code without abusing your space bar but also type résumé[^4] correctly.
I have found this absolutely invaluable in my German course. I am able to type something like *Linux ist großartig* without searching "eszet" and copying it from Wikipedia[^5].
## Usage
How you enable dead keys or the compose key depends *entirely* on your operating system. I'm sure most Linux distributions that ship with a DE[^6] like [GNOME](https://www.gnome.org/), [KDE](https://kde.org/), [XFCE](https://xfce.org/), etc. will have a GUI option in the settings. I use [Arch Linux](https://archlinux.org/) with [i3-gaps](https://github.com/Airblader/i3) and thus don't have a GUI to manage these kinds of things. That's where the [Arch Wiki](https://wiki.archlinux.org/index.php/) comes in.
Depending on whether you want dead keys or a compose key, there are different commands to run. I'm not sure how to enable the former—you'll need to read [the page for that](https://wiki.archlinux.org/index.php/Xorg/Keyboard_configuration) yourself—but mapping an existing key to compose is really easy.
List what your options are
```
grep "compose:" /usr/share/X11/xkb/rules/base.lst
```
Copy which first column you want and paste it into this command
```
setxkbmap -option <option-goes-here>
```
I mapped mine to the right `Alt` key as I never use it and it's near the space bar. The command for that would simply be:
```
setxkbmap -option compose:ralt
```
For other interesting things you can do with your keyboard, check [that whole section](https://wiki.archlinux.org/index.php/Xorg/Keyboard_configuration#Frequently_used_XKB_options) of the Arch Wiki. It's really one of the best resources there is for this kind of thing.
## Edit
Since the time of publication, I've started using [Wayland](https://wayland.freedesktop.org/) and configuring your keyboard with `setxkbmap` doesn't work. Instead, assuming you're running [sway](https://github.com/swaywm/sway/), add something along this vein to your config. If you want to use something other than your right `Alt` key, make sure you change that.
```
input type:keyboard xkb_options compose:ralt
```
[^1]: They're called dead keys because, with most keyboards and operating systems, there is no visual indication that it's been struck; the key appears to be dead.
[^2]: [Dictionary.com](https://www.dictionary.com/browse/diacritic?s=t): "*a mark, point, or sign added or attached to a letter or character to distinguish it from another of similar form, to give it a particular phonetic value, to indicate stress, etc.*&rdquo;
[^3]: Also known as a *multi key*
[^4]: Yes, résumé is the correct spelling. Resume is *accepted* but it's *more* correct with the diacritical[^2] marks.
[^5]: I also had to do the same when I wanted to add an [umlaut](https://wikipedia.org/wiki/Diaeresis_(diacritic)) to anything, as in *über*
[^6]: *DE* is short for *Desktop Environment*. If you're not familiar with the term, a DE is basically a suite of applications and programs that make up the interface a computer user interacts with. The dock on macOS, the start menu on Windows, your file manager, these are all examples of *tightly* integrated applications that provide the core functionality of whatever operating system you use.