Does anyone know how to disable unicode text input in text fields

cocoainternationalizationkeyboardunicode

I absolutely love the Cocoa text engine. A few modifications to a little xml file – ~/Library/DefaultKeyBinding.dict – and you can get just about any key sequence to work in any standard Cocoa text field in any application.

For example, I've added a bunch of emacs key bindings like CtrlA for going to the beginning of a line, F for moving forward a word, B for moving back a word, etc.

Anyhow, I've noticed that a few applications – even though they seem to use the Cocoa text engine and use standard Cocoa text field widgets – have this annoying way of subverting my emacs key bindings. In some text fields, the Option key is used to type Unicode international characters.

Is there any way of disabling this globally? I don't ever want the Option key to do this – if I want to type a Unicode character, I'll use the character viewer.

Any ideas?

Best Answer

Some applications and text views just don't support DefaultKeyBinding.dict.

If you create a new keylayout with Ukelele, you can for example make ⌥A insert nothing instead of å. Or you can reassign key combinations that enter dead key states (like ⌥U on the U.S. layout) so that they can be in used in DefaultKeyBinding.dict.

  • Keyboard layouts in ~/Library/Keyboard Layouts/ can't be selected in password dialogs or the login screen, but ones in /Library/Keyboard Layouts/ can.
  • XML keylayout files don't work with the popovers shown when holding keys, but keylayout bundles do.
  • To apply changes to a keylayout, you currently have to for example run sudo touch /Library/Keyboard\ Layouts/ and log out and back in.
  • The default input sources can be removed by editing ~/Library/Preferences/ByHost/com.apple.HIToolbox.*.plist.

KeyRemap4MacBook can for example change ⌥B to ⌥← in all applications except iTerm and Emacs. See this question.