Retired Document
Important: The information in this document has been superseded by the Text Editing chapter of Cocoa Text Architecture Guide.
About Key Bindings
The text input system uses a dictionary property list, called a key-bindings dictionary, to interpret keyboard events before passing them to the Input Method Kit framework for mapping to characters.
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 send the handleEvent:
message to its input context.
The input context 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 context
calls the text view’s doCommandBySelector:
method
with the selector associated with the dictionary entry.
If the input context cannot match the keyboard event to an entry in the key-bindings dictionary, it passes the event to the Input Method Kit for mapping to characters.
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.
Copyright © 2003, 2013 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2013-04-23