This repository contains scripts for macOS (using Hammerspoon) and Windows (planned, using AutoHotKey) for easy input of Unicode characters (and their LaTeX codes). It is inspired by the space-cadet keyboard and the pain of writing equations in emails or comments in PDF files.
The simplest and most common way to customize the behavior is by editing the Markdown tables and then rerunning the scripts.
If everything goes well, Cmd + F12 should toggle between Unicode and LaTeX output modes.
The following key combinations should produce
Caps Lock + d→ δ or\deltaCaps Lock + Shift + d→ Δ or\DeltaF12 + d→ ∂ or\partialF12 + Shift + d→ ∇ or\nabla
Currently, each keyboard key supports four combinations.
These combinations are saved in the Markdown tables (Table_X.md) of five columns.
The table is organized by keyboard lines (1234... vs asdf...).
The first two columns use CapsLock and CapsLock + Shift (which we call hyper) and are mainly for Greek charecters.
The last two columns use F12 (which we call meta) and are mainly for mathematical operators.
Note, that we map q to α because Hammerspoon has (had?) a problem with using a.
You need two programs:
The first one maps keys to something else. It is not strictly needed, since one could use only the existing keys for modifiers, e.g., F11 or F12. In this setup, I use Karabiner to map the Caps Lock key to F19.
In karabiner > Settings > Complex Modifications, click on Add your own rule and insert the following codes, which are in karabiner.md.
Note, that I only modify the Caps Lock (it maps to F19).
You can find Karabiner as a karabiner icon in the top bar.
- Parse the desired table (e.g., for Unicode mapping in
Table_unicode.md) into a dictionary (useparse_table.parse_table). - Write down the Lua configuration files for Hammerspoon (use
mac.mac.write_config) - Copy the scripts
unicode.luaandlatex.luainto~/.hammerspoon/. - Load the configuration file into Hammerspoon:
Hammerspoon > Open Configand copy the contents ofmac/init.lua.
You should write both scripts: for Unicode and LaTeX.
Everything is in write_config.py.
If you prefer to store the script in a different location (than ~/.hammerspoon/) or named differently,
you can change variables config1 and config2 in mac/init.lua
If you only want one script (Unicode without LaTeX), I guess this init.lua script should work:
pasteboard = hs.pasteboard.uniquePasteboard()
-- Define the paths to your configuration files
local config1 = os.getenv("HOME") .. "/.hammerspoon/unicode.lua"
dofile(config1)TODO