How to type special characters in Linux?

85

37

In windows there is possibility to type from keyboard special signs by holding alt key and typing a few numbers, that depends on with sign you want to use. Does it work with linux in the same way?

inothemo

Posted 2009-10-23T13:04:39.927

Reputation: 1 699

in windows, this does only work for ascii-codes, right? how to do so for unicode-characters? – FranBran – 2015-12-10T12:55:44.117

1frabra, not all applications support unicode input such way. But rather often starting number with zero helps, i. e. type Alt + 08212 for M-dash, instead of Alt + 8212. – Smylic – 2016-09-28T16:50:52.187

@FranBran you need to enable hex numpad and then you can input any Unicode characters

– phuclv – 2018-06-09T03:53:35.757

@Smylic that won't work for most applications because the decimal Alt-code will be modulo 256. You have to use hex numpad – phuclv – 2018-06-09T03:54:56.267

Answers

103

You can use Ctrl + Shift + u followed by the code in hex. (You only need to hold down Ctrl and Shift while typing the code)

John T

Posted 2009-10-23T13:04:39.927

Reputation: 149 037

5I use Compose (mapped as Right-Ctrl), which should work in all DEs since it is provided by X. Compose " A => ä, Compose g p i => "π", etc – Mark K Cowan – 2015-06-11T18:12:58.567

1for example: (1.) ctrl+shift+u (2.) hold down: ctrl + shift and type 2022 (3.) gets you: – Trevor Boyd Smith – 2018-02-15T18:02:02.310

Hint 1: For figuring out hex codes (of characters you havbe in your clipboard) go to the ishida unicode converter

– Frank Nocke – 2018-08-23T07:03:08.257

2john, do you know what supplies this functionality? i haven't heard of it before. where does it work, on the console? Ubuntu's defaults in GNOME? thx. – quack quixote – 2009-10-23T13:37:38.140

1found a similar source (minus the u, just hold down Ctrl+Shift) for "works in GNOME", and a method for VIM that uses the u but not the Shift. – quack quixote – 2009-10-23T13:58:12.020

8Thx, works for me. In Ubuntu's terminal (under X), I'm able to type Ctrl+Shift+U, let up all 3, and then type 66 followed by Space and I end up with "f" which is the correct character for 66 in UTF-8. It didn't work from tty1 (control-alt-F1 - non-graphical terminal) though. – Stan Kurdziel – 2013-03-22T23:23:42.417

2Any solution to KDE? – Jack – 2013-05-22T01:11:56.003

54

X uses something called the compose key. By pressing Compose, some key, some key… in sequence, you can input characters. I have my compose key set to Menu; to type a © (copyright symbol), I would use Menu, o, c.

A full list of X compose key combinations can be found online (200 KiB), or locally in /usr/share/X11/locale/en_US.UTF-8/Compose.

In Gnome, the compose key can be set by going to Preferences → Keyboard → Layouts tab → Layout Options → Compose key position.

virtuallinux

Posted 2009-10-23T13:04:39.927

Reputation: 661

2Perfect. Without GNOME, the compose key can be set through setxkbmap. For example, $ setxkbmap -option 'compose:menu' will set the "menu" key (between Alt Gr and right Ctrl on my keyboard) as the compose key. – Emil Lundberg – 2014-08-19T09:37:19.600

@mehaase Because, on my laptop, there is no available key for me to map as Compose. So I'll take an imperfect answer over the elegant one. – Cliff – 2015-08-11T21:47:43.297

Cliff, what strange laptop is that? I have a tiny laptop which has a "menu" key (which virtuallinux uses as Compose key, as do I). It doesn't have a free unused key? No "Windows" key you don't need in Linux anyway? Weird. – Jürgen A. Erhard – 2018-04-01T16:42:03.640

@Cliff, I managed to set it to “3rd level of Left Ctrl”, so spare key required; I hope you can find something that works for you. – Amir – 2018-09-25T16:56:29.937

12How does the "memorize unicode code points" answer have twice as many upvotes as the compose key? Insanity. – Mark E. Haase – 2013-08-22T19:10:36.010

28

Inputting Unicode characters in Linux varies. The UTF-8 and Unicode FAQ has a section containing different input methods:

  • Ctrl+Shift+U [unicode in hex] is defined in ISO 14755 and implemented by GTK2+, and works in GNOME-Terminal and other applications.
  • Ctrl+V u [unicode in hex] works in VIM.
  • Alt+[unicode in decimal using numpad digits] works at the console providing your environment is properly configured to expect UTF-8 (via LOCALE or LANG environment variables). (unicode_start manpage).

Other methods you could use:

  • Cut-n-paste characters from a small input file containing the characters you want.
  • Use xmodmap to remap keys in X (see the FAQ link above for examples).

quack quixote

Posted 2009-10-23T13:04:39.927

Reputation: 37 382

Sad world we live in when people have all but forgotten about the beauty of Compose. – Jürgen A. Erhard – 2018-04-01T16:42:46.583

2+1 for including VIM. I was curious how to do this in Intellij with VIM keybindings. – new123456 – 2012-02-18T03:35:12.580

(I removed the UTF8 tag you added to the question, as that is actually an encoding, which is not used when typing a character.) – Arjan – 2009-10-23T14:33:00.590

I can confirm that alt-numpad works for me in ubuntu 12.04's tty1 console (control-alt-F1) with $LANG=en_US.utf8 The codes are decimal, not hex though, so instead of 66 (hex) for "f", I hold Alt, type 102, let Alt up and out pops "f". – Stan Kurdziel – 2013-03-22T23:34:10.020

7

The Linux console also supports compose keys (The compose key is often Alt + AltGr or PrintScrn) - see How to define a Compose Key in terminal on the Unix and Linux Stack Exchange for details.

Anon

Posted 2009-10-23T13:04:39.927

Reputation: 73

0

There's a better method for both Linux and Windows than using alt-key codes that doesn't require you to remember any codes. It's described in detail here.

The gist is that you use AutoHotKey (Windows) or AutoKey (Linux). Both run in the background and accept arbitrary strings as trigger to run a command, which in this case is to send a special character to the clipboard and then paste it to whatever program is currently being used.

The example given has /delta as the trigger (including the forward slash). After typing those six characters, they are deleted and replaced with a δ.

hugke729

Posted 2009-10-23T13:04:39.927

Reputation: 109