2

The user specific keyBindings .dict file is found in: ~/Library/KeyBindings/

How can you (as the developer) tell AppKit to look in another directory (app specific) for another bindings file for your specific application. This does not need to override the user specific one as it could be for functionality other than text manipulation.

This could be useful for the following reason:

  1. Changing keyBindings for your app without messing with the users settings for the rest of their system (in particular where your objects are not neccesarily text input objects)
  2. Adding additional action methods not found in NSResponder

Quoting from the Cocoa Event Handling Developer Guide (page 68). Emphasis is mine.

It can pass the event to Cocoa’s text input management system by invoking the NSResponder method interpretKeyEvents:. The input management system checks the pressed key against entries in all relevant key-binding dictionaries and, if there is a match, sends a doCommandBySelector: message back to the view. Otherwise, it sends an insertText: message back to the view, and the view implements this method to extract and display the text.

Sam
  • 2,745
  • 3
  • 20
  • 42
  • As far as I can tell the user specific keyBindings file is "~/Library/KeyBindings/DefaultKeyBinding.dict"; I don't see any way for an application to override that (and it shouldn't; _USER_ preferences should always take precedence). Searching my /Applications folder I only found two apps that have KeyBinding.dict files (TextMate & Xcode). I'm guessing that they're using that file independently of anything the OS does. – geowar Mar 02 '15 at 15:46
  • @geowar I would think so as well except for the above excerpt from the Apple Developer Guide. It would also be quite useful to have some sort of a framework that you could hook into...hence my question. – Sam Mar 03 '15 at 08:35

1 Answers1

2

I don't believe it's possible. I think the bit about "all relevant key-binding dictionaries" is just referring to /System/Library/Frameworks/AppKit.framework/Resources/StandardKeyBinding.dict and ~/Library/KeyBindings/DefaultKeyBinding.dict.

Ken Thomases
  • 88,520
  • 7
  • 116
  • 154
  • I've confirmed (to my satisfaction) that those are the only two key-binding dictionaries looked at by Cocoa event handling. If you want to play with them copy the system one to the user one and start tweaking… YMMV, etc. ;-) – geowar Mar 21 '15 at 18:20