Writing about science often involves using symbols. Unfortunately, few of the symbols we need can be found on the keyboard, which presents a problem. It is not difficult to copy and paste symbols needed, but it is tedious and annoying. Here I present a solution that lets you input any symbol by simply typing its name (prepended with a slash).
The solution described below works for Windows (using AutoHotKey) or Linux (using AutoKey). These tools, among other things, can convert sequences of keystrokes to different, desired outputs. For example, if I were to type “/delta” or “/Delta” in any application, it would replace that text with δ or Δ, respectively.
In the example above, I’ve taken a LaTeX-like approach, but with a forward slash in place of the backslash (therefore not obstructing standard LaTeX commands). You don’t need to know a thing about LaTeX, however, to make use of this solution, and extending the delta example to any unicode character (i.e. any character ever) is easy.
If you are unfamilar with AutoHotKey, don’t worry, the instructions below are all you need.
1) Download AutoHotkey.
2) Download my AHK script here (it’s just a plain text file, with an .ahk extension).
3) Save the script in your startup folder so that it will run all the time. (To find your startup folder, simply type “startup” in Windows Explorer’s address bar and press enter.)
Add your own symbols
To add a new symbol is simple: Right-click on the .ahk file, choose “Edit Script”, and scroll to the bottom. By that stage you will see that it is self explanatory and you simply need to copy and paste and adjust to your liking. I recommend Unicode Lookup to search for symbols.
AutoHotKey, Inkscape, and unicode
Writing macros is often easy with AutoHotKey. However, I initially ran into trouble with Inkscape not accepting unicode characters sent by the script. To solve this problem, my script employs a method that sends the unicode character via the clipboard (equivalent to using copy and paste). Credit for this solution goes to Evgeni.
AutoKey, a Linux utility, is in many ways similar to AutoHotKey (not surprising, given the name).
1) Download the Python 3 version of AutoKey. (The original AutoKey used Python 2, which does not integrate as well with unicode characters. This work-around can help if you are stuck with the Python 2 version.)
Edit (April 2018): Autokey now uses Python 3 by default. See installation instructions in the link above. The original installation instructions for Linux Mint, Ubuntu, and possibly others were
# Install the original autokey sudo apt-get install autokey-gtk # Update autokey to python 3 using pip3 pip3 install --user autokey-py3
To run the application, try either
~/.local/bin/autokey-gtk or /usr/bin/autokey-gtk
Depending on your installation and Linux distribution, Autokey may not be installed to either of the locations noted above. Hence, you may need to first determine where it resides.
2) Open AutoKey and choose “New” from the toolbar, then “Phrase” from the dropdown menu
3) Give your phrase a name (e.g., the name of the character).
4) Paste the desired unicode character in the large, blank text box on the right.
5) For best results, select “Clipboard (Ctrl + V)” under the “Paste using” option.
6) At the bottom of the screen, you will see an option to “Set” an “Abbreviation”.
7) Choose Add, then type in your chosen abbreviation, e.g., /Delta for Δ.
8) Choose the appropriate options. The only required option is “Removed typed abbreviation”. I often check two additional boxes.
8 thoughts on “Add any symbol without leaving the keyboard”
This doesn’t work. I have added a phrase shorthand /tflip with the phrase (╯°□°）╯︵ ┻━┻), but the output is always (°° )
My first guess as to why it doesn’t work would be that the font is missing all the characters in your phrase. I’m basing this on the fact that it prints out a subset of your phrase
@hugke729, would you be kind enough to share your autokey/data folder. I would greatly appreciate to look at it and probably will make great use of it. I like how much time and organization you dedicated on automating your work.
Right now, they’re a bit of a mess and have some personal information. But I’ll hopefully have a go at some stage and then let you know
I imagine that you are quite occupied, so, if you have the time, please update your article of 2015 about Autokey. There is no such a folder as ~/.local/bin/, unless you did a custom installation. But, there is ~/.local/share/ which stores debug logs, etc.
In addition, not every ANSI extended character (ANSI 128 – 255) can be printed from a phrase. I can print é-acute from a phrase, but the “—” character doesn’t print. So, I made a keyboard macro which mimics the keyboard strokes as follows:
# alt+- mdash —
nbsp = ” ”
char = “2014”
ukey = “++u”
ctrl = “”
keyboard.send_keys(nbsp + ukey + char + ctrl + nbsp)
Thanks for the note. Autokey installation instructions change reasonably often, which may explain the discrepancies in directories. I’ve added a note in the post that ~/.local/bin may not be the correct directory, but it shouldn’t be too difficult to find the correct one.
As for your issue with the em-dash, I’m glad you found a work-around. I’ve posted an alternative work-around in case you’re interested.
Comments are closed.