[HOME]

Customizing MacOSX Key Bindings

Recently I've been looking into MacOSX's customizability of key bindings. As it turns out, MacOSX's key bindings are remarkably customizable, and for us emacs geeks a number of functions are available to make us feel at home. I've managed to recreate a remarkably emacs-like editing environment with my DefaultKeyBinding.dict, complete with ^X key combos, etc. If you're not familiar with how to use this file please check out Apple's page on Text System Defaults and Key Bindings, basically you just need to save it in ~/Library/KeyBindings/.

You may want to go straight to the resource links below if you're not familiar with how Mac OSX's key binding mechanism works.


Project Builder

Unfortunately, not all of the bindings in the DefaultKeyBinding.dict are honoured in the Project Builder, possibly because methods are named differently, etc, I'm not quite certain. You can provide it with it's own key bindings in PBXKeyBinding.dict or PBKeyBinding.dict for the latest Project Builder (v1.1.1). I'm not quite satisfied with my current binding configuration so I won't include it here, yet.


Completion

One really cool feature I've found is the 'complete' method provided by the NSResolver class. It appears to be overriden in usefull ways by different applications/classes such as the 'Open' dialog for files which allows you to do filename completion through this method, or the Project Builder which will complete function names, variable names, etc! Bind it to a dedicated key you find handy and enjoy. I recommend M-/ (AKA Option-/) as emacs appears to have some form of completion attached to that. Take a look at my DefaultKeyBinding.dict file for an example of how to bind this.


Links to Resources

There are several resources which document how to customize your key bindings, here's a list of the ones I've found usefull or worth mentioning, at least:

Text System Defaults and Key Bindings
This page describes the basic mechanism used for binding keys for Cocoa apps and documents some other options available. It also provides a sample key binding file.
NSResponder Documentation for Objective-C
The NSResponder class is described here, it is an abstract class inherited-from by core classes in Cocoa apps. It document methods which are generally available in every Cocoa Application, Window, etc, which are in turn made available for key bindings. Applications and other classes may override these methods or add to them, it'd probably be a worthy project to document which methods are available from which applications or classes for key binding.
TextExtras developer utility
This is a handy add-on that adds text handling features which can be bound to keys through the mechanism described above. The package also include a fairly extensive DefaultKeyBinding.dict example which I've used extensively for my own key bindings. TextExtras is pretty neat and the source is included, so I'm hoping to make or find some kind of isearch method available through a similar add-on someday.
Cocoa App KeyBinding Descriptions at gnufoo.org
This repeats the information at the Text System Defaults and Key Bindings mentioned page above, adding a few more thoughts and comments on it. There are other great gems there, worth checking out.
More Discussion at www.macosxhints.com
More repeat of the information above, plus a little discussion.

[HOME]


MisakA
Last modified: Mon Dec 10 10:59:14 EST 2001