4

I would like to be able to insert a Unicode character, namely š, by pressing a keyboard shortcut in OSX. Some applications allow me to press and hold the s key and then I can select the desired accented form. However, some applications, such as iTerm2 or LibreOffice don't seem to respect this.

My daughter's name is Eliška and I'd like to be able to type her name from anywhere.

The trick from here doesn't work for me. I even tried adding a Unicode string.

I also tried cloning KeyRemap4MacBook to try and add the X11 key code to the list of available codes for mapping. This compiled fine and the private.xml file was loaded and parsed properly (meaning the new key code was recognized) but the mapping just doesn't work.

Unicode for this character is U+0160 and U+0161. Here is the Wikipedia entry.

Any ideas?

EDIT: Solved for iTerm2 by adding a keyboard shortcut in iTerm2's preferences.

4 Answers 4

3

Did you try the text substitution option in System Preferences?

  1. Go to System Preferences
  2. Go to the "Language & Text" pane, click on the "Text" pane (or simply search for substitution to go directly to that pane)
  3. Make sure that "Use symbol and text substitution" is enabled.
  4. Click the "+" icon at the bottom of the list of substitutions.
  5. Add a new entry. I used "Eliska" in the replace column and "Eliška" in the "with" column.

The substitution worked for me in TextEdit, but not in this text entry window. It also seemed to be ignored in Excel. It'll probably work better in apps which use Apple frameworks and use rich text (not plain ascii).

1
  • 1
    Yes, I did try that and it worked fine for me in TextEdit just as you say. It really needs to work everywhere though. Thanks Commented Jan 30, 2013 at 18:05
1

You can also use Ukelele to create a custom keyboard layout.

  1. Choose File > New Based on Current Input Source.
  2. Edit the layout and save it as a bundle to /Library/Keyboard Layouts/. Keyboard layouts in the user library aren't selected by default in password dialogs. The popovers shown when holding keys don't work with normal keylayout files.
  3. Log out and back in.
  4. Enable the input source in System Preferences.

To apply changes, you have to log out and back in after for example touching /Library/Keyboard Layouts/.

You can disable the default input sources by removing them from ~/Library/Preferences/ByHost/com.apple.HIToolbox.*.plist and logging out and back in.

TextExpander also works in iTerm and many cross platform applications. I have removed most non-ASCII characters from my custom keyboard layout, because abbreviations like scaron are often easier to remember and configure.

0

I recently used the following method to solve a similar issue: I wanted to be able to type a narrow no-break space using a keyboard shortcut, since this is my preferred whitespace between a value and units (e.g. 62 mm). I settled on opt-shift-space.

  1. Create the directory ~/Library/KeyBindings if it doesn’t already exist.
  2. Create a text file at ~/Library/KeyBindings/DefaultKeyBinding.dict.
  3. Copy and paste the text below into your file, and change it to suit your needs. Lines beginning with // are comments. The uncommented line implements the narrow non-breaking space, while the commented lines below that contain examples from the original source.
    {
    // ~ = Option
    // $ = Shift
    
    "$~ " = (insertText:, " ");
    
    //"~v" = (insertText:, "✓");
    //"~b" = (insertText:, "●");
    //"~c" = (insertText:, "⌘");
    //"~t" = (insertText:, "👍");
    //"$~T" = (insertText:, "👎");
    }
    
  4. Quit and restart any open applications to take effect.
  5. The new keyboard shortcuts should now be active in any text field.

Source: Zach Waugh

0

In continuation to SpinUp__A Davis's answer you can also use (in the same ~/Library/KeyBindings/ location and using DefaultKeyBinding.dict as file name) the recommended dictionary format using xml property list

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>$~ </key>
    <array>
        <string>insertText:</string>
        <string> </string>
    </array>
    <!-- <key>~c</key>
    <array>
        <string>insertText:</string>
        <string>⌘</string>
    </array> -->
    <!-- <key>~t</key>
    <array>
        <string>insertText:</string>
        <string>👍</string >
    </array> -->
</dict>
</plist>

this will have a better chance to withstand latest Mac updates.

when adding invisible Unicode characters the XML syntax is &#x followed by the character code and then a semicolon (;) for instance to add the Unicode U+200F Right-to-Left Mark (RLM) to ⌥ + d you will add

    <key>~d</key>
    <array>
        <string>insertText:</string>
        <string>&#x200F;</string>
    </array>
New contributor
yehsuf is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .