Keyboards are able to support a wide range of languages. However, they do not send the actual characters produced by pressing their keys - instead, they send numerical codes. In the USB HID spec, these are called "usages", although they are more often referred to as "scancodes" or "keycodes" when in the context of keyboards. Less than 256 usages are defined in the HID Keyboard/Keypad usage page, and some of those do nothing on modern operating systems. So, how is this language support achieved?
In a nutshell, the operating system maps the usages it receives to the appropriate character based on the user's configured keyboard layout. For example, when a Swedish person presses the key with the
å character printed on it, the keyboard is actually sending the keycode for
Obviously, this could get confusing, so QMK provides language-specific keycode aliases for many keyboard layouts. These won't do much on their own - you still have to set the matching keyboard layout in your OS settings. Think of them more as keycap labels for your keymap.
To use these, simply
#include the corresponding header file in your
keymap.c, and add the keycodes defined in them in place of the
KC_ prefixed ones:
Canadian Multilingual (CSA)
English (US International)
French (macOS, ISO)
Italian (macOS, ANSI)
Italian (macOS, ISO)
There are also a few which are not quite language-specific, but useful if you are not using a QWERTY layout:
SEND_STRING() assumes a US ANSI keyboard layout is set. If you are using a different layout, you can also
#include "sendstring_*.h" (as above) in your keymap to override the lookup tables used for mapping ASCII characters to keycodes.
An important thing to note here is that
SEND_STRING() only operates on ASCII text. This means that you cannot pass it a string containing Unicode characters - this unfortunately includes accented characters that may be present in your desired layout.
Many layouts make certain characters, such as Grave or Tilde, available only as dead keys, so you must add a space immediately after it in the string you want to send, to prevent it from potentially combining with the next character.
Certain other layouts have no Sendstring header as they do not use a Latin-derived alphabet (for example Greek and Russian), and thus there is no way to input most of the ASCII character set. These are marked above with a