Typing "↑" (upwards arrow) with a keyboard shortcut

112,669

Solution 1

If you look at the file /usr/share/X11/xkb/symbols/latin, you will find the following lines:

key <AD06>  { [         y,          Y,    leftarrow,          yen ] };
key <AD07>  { [         u,          U,    downarrow,      uparrow ] };
key <AD08>  { [         i,          I,   rightarrow,     idotless ] };
key <AD06>  { [         z,          Z,    leftarrow,          yen ] };

So apparently an up arrow (↑) is already defined -- for ALT GR+SHIFT+U. If not, you can copy the file to a directory, edit it at will, name the profile somehow (say "foo" instead of "latin") and simply run

setxkbmap -I. -layout foo

(the -I. makes setxkbmap look for layout files also in the current directory).

The four strings assign to each key give the four characters that are produced by pressing the key, key with shift, key with altgr and key with algr+shift. The names of the entities (keysyms) that xkb can recognize can be found here.

Solution 2

Alternatively you can enable compose keys to create these symbols or even strings of text with ease.

Open GEdit and insert the following:

include "/usr/share/X11/locale/en_US.UTF-8/Compose"

<Multi_key>     <1>     <2>     <3> : "Your text or symbol"     # Quick description
<Multi_key>     <o> : "↑"  U2191    # up arrow
<Multi_key>     <y> : "←"  U2191    # left arrow
<Multi_key>     <i> : "→"  U2191    # right arrow
<Multi_key>     <u> : "↓"  U2191    # down arrow

Save this as .XCompose (case sensitive) in your home directory.

Open your keyboard settings (system settings → keyboard settings) and go to the shortcuts tab. Under the "typing" section you'll find a "Compose Key" setting. Set this to your compose key (I advice right alt to keep your know shortcuts)

Gnome Compose Key setting for gnome
Unity Compose Key setting for Unity Xfce
Compose Key setting for xfce. Source: wikipedia Compose Key

Log out and log back in.
To quickly summon your symbols press the following keys in sequence Compose Key123.
Just replace 1,2,3,4,5 etc etc with whatever keys you want to use.

If it isn't working add

export GTK_IM_MODULE="xim"

to the end of ~/.profile. If xim isn't working for you you'll have have to install uim (sudo apt-get install uim) and replace the xim in ~/.profile with uim and logout and log back in.

Solution 3

A GUI Alternative: indicator-chars

Installing this small indicator will let you easily insert characters like this without having to memorize many key combinations:

https://github.com/Sadi58/indicator-chars

enter image description here

Share:
112,669
franzlorenzon
Author by

franzlorenzon

Updated on September 18, 2022

Comments

  • franzlorenzon
    franzlorenzon over 1 year

    When I'm programming, I find useful to use some unicode symbol like ← ↓ → to indicate in comments different things.

    In Ubuntu I can type ← ↓ → respectively with Alt Gr + Y, Alt Gr + U, Alt Gr + I.

    But to get the symbol "↑" I have to type Ctrl + Shift + U , and then 2191 (i.e. I have to insert the unicode code).

    Is there a shortcut for the upwards arrow? If there isn't, how could I manually add it?

    • Dan
      Dan over 10 years
      Didn't know about any of this stuff, used to go to a browser, search the Internet and copy paste them to a terminal.
    • January
      January over 10 years
      Maybe there is a better way, but I solve these things by creating my own key map files. Look at the files in /usr/share/X11/xkb/symbols/, copy and modify one of them, load it with setxkbmap.
    • franzlorenzon
      franzlorenzon over 10 years
      @Dan, and there are many others with direct shortcuts, like ¹,²,³, ¼, ½, «, » etc . @ january thanks, I'll have a look at that
    • franzlorenzon
      franzlorenzon over 10 years
      For a guide to use them: help.ubuntu.com/community/…
  • franzlorenzon
    franzlorenzon over 10 years
    It works, and by the way it's very logical to have ↑ from ↓ by pressing shift as an additional key in the combination :)
  • Paddy Landau
    Paddy Landau over 10 years
    @January Thank you for sharing the latin file, something that I had wanted to know about. Would you know where the codes for the Shift+AltGr combination are kept? E.g., Shift+AltGr, -, > also gives ; note that this is different from AltGr+Shift, -, >
  • Erbureth
    Erbureth about 8 years
    Using RAlt as Compose key is IMHO bad idea, as it is already 3rd and 4th level shift. I am using Caps Lock.
  • Akisame
    Akisame about 8 years
    The right super key is the best if your keyboard has it (IMO). The pause key is also quite useful but it really is a matter of opinion.
  • EKons
    EKons over 7 years
    All four of your arrows seem to say U2191. Is that correct?
  • Akisame
    Akisame over 7 years
    no but it doesn't really matter. I use it without all the U codes but you can add it...
  • Jürgen A. Erhard
    Jürgen A. Erhard about 7 years
    I use the menu key between right alt (Alt Gr) and right ctrl as compose, both in Linux and in Windows (there using the wonderful WinCompose... in case you "have to" use Windows)
  • Madivad
    Madivad over 6 years
    this is always one of the first "fixes" I install. I can't live without compose lol
  • Akisame
    Akisame over 6 years
    true. especially if you need to type a lot of special symbols on a regular basis. There is even a windows version of this for when you 'need' to use a windows pc (WinCompose) that works almost identical to the linux version.
  • wjandrea
    wjandrea over 6 years
    -1 This works on Windows, not Ubuntu.
  • wjandrea
    wjandrea about 4 years
    January's answer already mentioned AltGr+Shift+U