< Previous PageNext Page > Hide TOC

About Key Bindings

Input managers use a dictionary property list, called a key-bindings dictionary, to interpret keyboard events before passing them to an input server.

During the processing of a keyboard event, the event passes through the NSMenu object, then to the first responder via the keyDown: method. The default implementation of the method provided by the NSResponder class propagates the message up the responder chain until an overridden keyDown: implementation stops the propagation. Typically, an NSResponder subclass can choose to process certain keys and ignore others (for example, in a game) or to call the interpretKeyEvents: method, which passes the event to the current input manager.

The input manager checks the event to see if it matches any of the keystrokes in the user’s key-bindings dictionary. A key-bindings dictionary maps a keystroke (including its modifier keys) to a method name. For example, the default key-bindings dictionary maps ^d (Control-D) to the method name deleteForward:. If the keyboard event is in the dictionary, then the input manager calls the input server’s doCommandBySelector:client: method with the selector associated with the dictionary entry. If the input server’s doCommandBySelector:client: method doesn’t find a matching method, then it passes the command selector onto the text view’s doCommandBySelector: method, which may or may not find a matching method to call.

If the input manager cannot match the keyboard event to an entry in the key-bindings dictionary, it extracts the string from the event by using its characters method and passes the returned characters to the input server’s insertText:client: method.

The standard key-bindings dictionary is in the file /System/Library/Frameworks/AppKit.framework/Resources/StandardKeyBinding.dict. You can override the standard dictionary entirely by providing a dictionary file at the path ~/Library/KeyBindings/DefaultKeyBinding.dict. However, defining custom key bindings dynamically (that is, while the application is running) is not supported.



< Previous PageNext Page > Hide TOC


© 1997, 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-02-08)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.