Skip to content

Instantly share code, notes, and snippets.

@borama
Created August 1, 2025 10:16
Show Gist options
  • Select an option

  • Save borama/5ee26a56e27f444d0771f7eb765666f6 to your computer and use it in GitHub Desktop.

Select an option

Save borama/5ee26a56e27f444d0771f7eb765666f6 to your computer and use it in GitHub Desktop.
Karabiner script to input Unicode characters
{
"description": "Unicode characters",
"manipulators": [
{
"description": "arrow right",
"from": {
"key_code": "i",
"modifiers": { "mandatory": ["left_option"] }
},
"to": [
{ "apple_vendor_top_case_key_code": "keyboard_fn" },
{
"key_code": "2",
"modifiers": "right_option"
},
{
"key_code": "1",
"modifiers": "right_option"
},
{
"key_code": "9",
"modifiers": "right_option"
},
{
"key_code": "2",
"modifiers": "right_option"
},
{ "apple_vendor_top_case_key_code": "keyboard_fn" }
],
"type": "basic"
},
{
"description": "arrow left",
"from": {
"key_code": "i",
"modifiers": { "mandatory": ["left_option", "left_shift"] }
},
"to": [
{ "apple_vendor_top_case_key_code": "keyboard_fn" },
{
"key_code": "2",
"modifiers": "right_option"
},
{
"key_code": "1",
"modifiers": "right_option"
},
{
"key_code": "9",
"modifiers": "right_option"
},
{
"key_code": "0",
"modifiers": "right_option"
},
{ "apple_vendor_top_case_key_code": "keyboard_fn" }
],
"type": "basic"
},
{
"description": "multiplication sign",
"from": {
"key_code": "x",
"modifiers": { "mandatory": ["left_option"] }
},
"to": [
{ "apple_vendor_top_case_key_code": "keyboard_fn" },
{
"key_code": "0",
"modifiers": "right_option"
},
{
"key_code": "0",
"modifiers": "right_option"
},
{
"key_code": "d",
"modifiers": "right_option"
},
{
"key_code": "7",
"modifiers": "right_option"
},
{ "apple_vendor_top_case_key_code": "keyboard_fn" }
],
"type": "basic"
},
{
"description": "em dash",
"from": {
"key_code": "w",
"modifiers": { "mandatory": ["left_option"] }
},
"to": [
{ "apple_vendor_top_case_key_code": "keyboard_fn" },
{
"key_code": "2",
"modifiers": "right_option"
},
{
"key_code": "0",
"modifiers": "right_option"
},
{
"key_code": "1",
"modifiers": "right_option"
},
{
"key_code": "4",
"modifiers": "right_option"
},
{ "apple_vendor_top_case_key_code": "keyboard_fn" }
],
"type": "basic"
},
{
"description": "n dash",
"from": {
"key_code": "h",
"modifiers": { "mandatory": ["left_option"] }
},
"to": [
{ "apple_vendor_top_case_key_code": "keyboard_fn" },
{
"key_code": "2",
"modifiers": "right_option"
},
{
"key_code": "0",
"modifiers": "right_option"
},
{
"key_code": "1",
"modifiers": "right_option"
},
{
"key_code": "3",
"modifiers": "right_option"
},
{ "apple_vendor_top_case_key_code": "keyboard_fn" }
],
"type": "basic"
},
{
"description": "superscript 1",
"from": {
"key_code": "1",
"modifiers": { "mandatory": ["left_option", "left_shift"] }
},
"to": [
{ "apple_vendor_top_case_key_code": "keyboard_fn" },
{
"key_code": "0",
"modifiers": "right_option"
},
{
"key_code": "0",
"modifiers": "right_option"
},
{
"key_code": "b",
"modifiers": "right_option"
},
{
"key_code": "9",
"modifiers": "right_option"
},
{ "apple_vendor_top_case_key_code": "keyboard_fn" }
],
"type": "basic"
},
{
"description": "superscript 2",
"from": {
"key_code": "2",
"modifiers": { "mandatory": ["left_option", "left_shift"] }
},
"to": [
{ "apple_vendor_top_case_key_code": "keyboard_fn" },
{
"key_code": "0",
"modifiers": "right_option"
},
{
"key_code": "0",
"modifiers": "right_option"
},
{
"key_code": "b",
"modifiers": "right_option"
},
{
"key_code": "2",
"modifiers": "right_option"
},
{ "apple_vendor_top_case_key_code": "keyboard_fn" }
],
"type": "basic"
},
{
"description": "superscript 3",
"from": {
"key_code": "3",
"modifiers": { "mandatory": ["left_option", "left_shift"] }
},
"to": [
{ "apple_vendor_top_case_key_code": "keyboard_fn" },
{
"key_code": "0",
"modifiers": "right_option"
},
{
"key_code": "0",
"modifiers": "right_option"
},
{
"key_code": "b",
"modifiers": "right_option"
},
{
"key_code": "3",
"modifiers": "right_option"
},
{ "apple_vendor_top_case_key_code": "keyboard_fn" }
],
"type": "basic"
},
{
"description": "single low quotation mark",
"from": {
"key_code": "4",
"modifiers": { "mandatory": ["left_option", "left_shift"] }
},
"to": [
{ "apple_vendor_top_case_key_code": "keyboard_fn" },
{
"key_code": "2",
"modifiers": "right_option"
},
{
"key_code": "0",
"modifiers": "right_option"
},
{
"key_code": "1",
"modifiers": "right_option"
},
{
"key_code": "a",
"modifiers": "right_option"
},
{ "apple_vendor_top_case_key_code": "keyboard_fn" }
],
"type": "basic"
},
{
"description": "left single quotation mark",
"from": {
"key_code": "5",
"modifiers": { "mandatory": ["left_option", "left_shift"] }
},
"to": [
{ "apple_vendor_top_case_key_code": "keyboard_fn" },
{
"key_code": "2",
"modifiers": "right_option"
},
{
"key_code": "0",
"modifiers": "right_option"
},
{
"key_code": "1",
"modifiers": "right_option"
},
{
"key_code": "8",
"modifiers": "right_option"
},
{ "apple_vendor_top_case_key_code": "keyboard_fn" }
],
"type": "basic"
},
{
"description": "right double quotation mark",
"from": {
"key_code": "6",
"modifiers": { "mandatory": ["left_option", "left_shift"] }
},
"to": [
{ "apple_vendor_top_case_key_code": "keyboard_fn" },
{
"key_code": "2",
"modifiers": "right_option"
},
{
"key_code": "0",
"modifiers": "right_option"
},
{
"key_code": "1",
"modifiers": "right_option"
},
{
"key_code": "d",
"modifiers": "right_option"
},
{ "apple_vendor_top_case_key_code": "keyboard_fn" }
],
"type": "basic"
},
{
"description": "right single quotation mark",
"from": {
"key_code": "7",
"modifiers": { "mandatory": ["left_option", "left_shift"] }
},
"to": [
{ "apple_vendor_top_case_key_code": "keyboard_fn" },
{
"key_code": "2",
"modifiers": "right_option"
},
{
"key_code": "0",
"modifiers": "right_option"
},
{
"key_code": "1",
"modifiers": "right_option"
},
{
"key_code": "9",
"modifiers": "right_option"
},
{ "apple_vendor_top_case_key_code": "keyboard_fn" }
],
"type": "basic"
},
{
"description": "double low-9 quotation mark",
"from": {
"key_code": "8",
"modifiers": { "mandatory": ["left_option", "left_shift"] }
},
"to": [
{ "apple_vendor_top_case_key_code": "keyboard_fn" },
{
"key_code": "2",
"modifiers": "right_option"
},
{
"key_code": "0",
"modifiers": "right_option"
},
{
"key_code": "1",
"modifiers": "right_option"
},
{
"key_code": "e",
"modifiers": "right_option"
},
{ "apple_vendor_top_case_key_code": "keyboard_fn" }
],
"type": "basic"
},
{
"description": "left double quotation mark",
"from": {
"key_code": "9",
"modifiers": { "mandatory": ["left_option", "left_shift"] }
},
"to": [
{ "apple_vendor_top_case_key_code": "keyboard_fn" },
{
"key_code": "2",
"modifiers": "right_option"
},
{
"key_code": "0",
"modifiers": "right_option"
},
{
"key_code": "1",
"modifiers": "right_option"
},
{
"key_code": "c",
"modifiers": "right_option"
},
{ "apple_vendor_top_case_key_code": "keyboard_fn" }
],
"type": "basic"
},
{
"description": "degree sign",
"from": {
"key_code": "0",
"modifiers": { "mandatory": ["left_option", "left_shift"] }
},
"to": [
{ "apple_vendor_top_case_key_code": "keyboard_fn" },
{
"key_code": "0",
"modifiers": "right_option"
},
{
"key_code": "0",
"modifiers": "right_option"
},
{
"key_code": "b",
"modifiers": "right_option"
},
{
"key_code": "0",
"modifiers": "right_option"
},
{ "apple_vendor_top_case_key_code": "keyboard_fn" }
],
"type": "basic"
}
]
}
@borama
Copy link
Author

borama commented Aug 1, 2025

This is a sample configuration for Karabiner Elements that allows to define keyboard shortcuts for typing Unicode characters in MacOS. I've seen other solutions using bash scripts but this one leverages a different route: it simulates temporary switching the input source to the "Unicode Hex Input" and typing the Unicode character hex code while the Option key is pressed. For this to work, the Unicode Hex input source must be enabled in settings.

@ttarchala
Copy link

ttarchala commented Mar 13, 2026

I can't make it work, even though I installed the Unicode Hex Input in my list of sources. I'm getting a series of 4 characters when I press the defined key, instead of the output character. Example: your first shortcut to produce the right arrow.

Perhaps it's the fact that my right option is remapped to right command (but my right command is also remapped to right option)?

image

@borama
Copy link
Author

borama commented Mar 13, 2026

To be frank, the solution above also tends to work for me only in some applications but not in others, and in yet others it behaves randomly… I was not able to find the root cause for that yet. In my case, when it fails, it also prints a series of weird characters. I guess it's some kind of timing issue but who knows, sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment