Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

There might be more simple ways than the one I am mentioning below.

What you're describing in essence boils down to: which has precedence over the other, the keyboard layout or the DefautlKeyBinding.dict. This part I can't answer. However I know how to prevent Unicode characters production when using either of or both option and control modifier keys.

I used Ukelele to make a custom keyboard layout for another language. For your situation, I would make a new keyboard layout based on my current keyboard layout, then delete all characters produced while holding either/both option and control modifier keys.

I have used it personally to produce my own keyboard layout for Arabic and it does what it was intended to do.

After you customise your keyboard layout, all you have to do is place it inside your home folder's Library/Keyboard Layouts/ folder. Of course you have to create it if it is not already present.

Please note that some application have their own hardcoded key bindings, specially text editing applications. So, this answers only the part in regard to disabling the Unicode characters produce with option and control keys.

share|improve this 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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.