How to type unicode characters in KDE?

15,469

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

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).

Solution 5

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.

Share:
15,469

Related videos on Youtube

agentofuser
Author by

agentofuser

I'm a software engineer with 15+ years of experience. I have written front-end and back-end code used by millions of people while at Qype GmbH (acquired by Yelp). I'm currently specializing in React, IPFS, and functional programming. I have designed, implemented, and marketed products from the ground up, lead teams of engineers, and founded my own startups, one them funded in the Start-Up Chile program. I have worked remotely for many years, both on open source projects (3x participant in the Google Summer of Code program) and commercial ones. I'm a good communicator and team member. I'm self-directed and disciplined with my time. I studied Computer Engineering at Brazil's (often ranked as) #1 higher education and research institution (both in general and specifically in Computer Science): University of Campinas. I've lived for almost 2 years in the United States. I can read, write, and speak English fluently. Feel free to get in touch at [email protected]. More contact information at https://agentofuser.com.

Updated on September 17, 2022

Comments

  • agentofuser
    agentofuser over 1 year

    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)?

  • Mark E. Haase
    Mark E. Haase over 9 years
    +1 "Memorising hexcodes is madness." → Couldn't agree more, but I'm surprised that my compose file doesn't contain some useful characters, like ✓ (u2713). The GitHub you linked to is supremely useful.
  • user2284570
    user2284570 over 8 years
    @daxim and if I need to enter ascii control characters?
  • John Smith
    John Smith over 8 years
    Add them to /usr/include/X11/keysymdef.h in the #ifdef XK_LATIN1 section and recompile X. You should now be able to type them via Compose key.
  • teekarna
    teekarna over 5 years
    Using the compose key is indeed helpful. But this answer does not answer the original question. AFAIK there's no method in KDE at the moment that would allow inserting any Unicode character using it's code. E.g. how would you type U+2620, i.e. ☠? The only way is to add a custom key combo, which is not ideal.
  • John Smith
    John Smith over 5 years
    Sometimes one has to "unask" the question. /// kragen xcompose contains ☠, it is made usable by the system by copying a file, it can't get easier than that.
  • Christian Hujer
    Christian Hujer over 5 years
    Compose is not a solution. The number of possible characters that I would like to type from the unicode exceeds what is mappable with compose in a mnemonic way. Memorizing non-mnemonic compositions is equal madness. And there's characters like RTL, LTR, RTL-override, Variant selection, Unicode flags, all those various emojis, and so forth - I'm fine with memorizing hex codes, and sometimes I haven't memorized a hex code, but look it up and just want that to type that character by hex code. Compose is not an answer, and unasking this question is not helpful but ignorant!
  • Christian Hujer
    Christian Hujer over 5 years
    Besides, messing around with compose or even recompiling X is NOT a viable solution for a lot of users!
  • John Smith
    John Smith over 5 years
    Christian, your assessment is wrong. It only makes sense if one ignores the existence of character map applications. Also, copying a file into the home directory is always a viable solution for any user.
  • Carolus
    Carolus almost 5 years
    I disagree that memorizing arbitrary combinations with mnemonics that are specific to Xorg is better than memorizing arbitrary combinations without mnemonics that are universal.
  • DavidPostill
    DavidPostill about 4 years
    Please quote the essential parts of the answer from the reference link(s), as the answer can become invalid if the linked page(s) change.
  • Christian Hujer
    Christian Hujer over 3 years
    The point is also about this: I already have memorized lots of codepoints. I know that U+2022 is the middot, U+21D2 is the double arrow right, and so on. I have memorized that U+FE0F is emoji and U+FE0E is text mode. I have memorized more code points than reasonably can be memorized using keyboard shortcuts. All I want, and probably the OP as well, is an efficient way to enter this. We do not want to force other people to memorize codepoints. We want a solution for people that have memorized or work with codepoints. For us, mapping specific code points does not work.