How to type unicode characters in KDE?

This answer has tips on how to do it on Gnome or Vim, but these don't work on KDE. This bug shows that KDE don't support the ISO notation with Ctrl+Shift plus the character's hex code. Is there any other way I can do this with a keyboard (that is, without copying and pasting)?


Solution 1:

Memorising hexcodes is madness. Use the compose key instead. It lets you combine characters in a mnemonic way. This is a feature of X, not just KDE, thus works everywhere. Some examples:

  • Compose, v, C   →   Č
  • Compose, ´, E   →   É
  • Compose, _, u   →   ū
  • Compose, ^, i   →   î
  • Compose, ,, S   →   Ş
  • Compose, +, o   →   ơ
  • Compose, ;, a   →   ą
  • Compose, U, g   →   ğ
  • Compose, ", u   →   ü
  • Compose, °, A   →   Å
  • Compose, ~, N   →   Ñ
  • Compose, +, -   →   ±
  • Compose, ., >   →   ›
  • Compose, ., .   →   …
  • Compose, ., =   →   •
  • Compose, P, !   →   ¶
  • Compose, !, ^   →   ¦
  • Compose, !, !   →   ¡
  • Compose, ?, ?   →   ¿
  • Compose, s, s   →   ß
  • Compose, o, e   →   œ
  • Compose, O, E   →   Œ
  • Compose, a, e   →   æ
  • Compose, A, E   →   Æ

Each key is typed sequentially without holding down. See the file /usr/share/X11/locale/en_US.UTF-8/Compose (online, 124 KiB) for the whole list. You can define your own compose sequences in your ~/.XCompose file (example).

Since I do not have a Sun keyboard, I do not have a physical Compose key. I remap the useless Caps Lock key as logical Compose key. Change this in System Settings → Region/Language → Keyboard Layout (kxkb applet) → tab Advanced → section Compose key position, or run the command setxkbmap -option compose:caps.

Solution 2:

Here is the KDE bug on the issue: https://bugs.kde.org/show_bug.cgi?id=103788

I addressed this issue in an article that deals with typing RTL text. Although in most common desktop environments Unicode symbols can be typed by holding the Alt key and pressing the numeric keypad plus sign then the Unicode value in hex, KDE users cannot use this method as KDE relegates responsibility for implementing this feature to Xorg, and Xorg relegates to Qt, and Qt relegates back to Xorg.

Solution 3:

Have a look at this article: Unicode Easy Keyboard Layout for XKB

Solution 4:

Install ibus-gtk3 (other input method frameworks, and certainly other ibus UIs may provide similar features, but this is what I tested).

This provides a unicode input dialog under the label of "Emoji choice". The default shortcut to bring this up is Ctrl+Shift+E.

You may have been hoping for a dialog-less solution, but it can still be used, efficiently, with the keyboard alone, i.e. Ctrl+Shift+E, [hexcode], Enter. This method also seems to work across apps of different toolkits, including KDE / Qt apps, Libreoffice, Chromium, Firefox, xterm, etc.

Solution 5:

Yet another method to type Unicode character in KDE is to use KRunner — it has Special Characters plugin enabled by default. Hit Alt + Space and enter #code and press Enter. For example, #2019 will produce single quotation mark. Still needs copy/paste though.
You can set aliases for the frequently used combinations in plugin's settings. For example, if you set sq alias for the code 2019 you can type #sq in KRunner and get the same result.
If these aliases don't work at once, restart KRunner with kquitapp5 krunner command (it was a bug in older Plasma 5 versions which should be fixed now).