Skip to content

Instantly share code, notes, and snippets.

@hym3242
Last active July 4, 2024 16:50
Show Gist options
  • Save hym3242/8e8bc10a2fed8e55973c500f1798c234 to your computer and use it in GitHub Desktop.
Save hym3242/8e8bc10a2fed8e55973c500f1798c234 to your computer and use it in GitHub Desktop.
Dump of /System/Library/Frameworks/AppKit.framework/Resources/StandardKeyBinding.dict on macOS Ventura 13.4, plus some notes
$ # plz forgive this dumb method of visualization.
$ cp /System/Library/Frameworks/AppKit.framework/Resources/StandardKeyBinding.dict .
$ plutil -convert xml1 StandardKeyBinding.dict
$ plutil -p StandardKeyBinding.dict | unicode-vis | cat -v | tr '\t' '+'
{
"^C" => "insertNewline:"
"^H" => "deleteBackward:"
"^Y" => "insertBacktab:" //shift+tab
"^[" => "cancelOperation:"
"^?" => "deleteBackward:"
"+" => "insertTab:"
"
" => "insertNewline:"
"^M" => "insertNewline:"
"@" => "noop:"
"@^?" => "deleteToBeginningOfLine:"
"@ " => "cycleToNextInputScript:"
"@." => "cancelOperation:"
"@^ " => "togglePlatformInputSystem:"
"@^U+F701" => "makeBaseWritingDirectionNatural:"
"@^U+F702" => "makeBaseWritingDirectionRightToLeft:"
"@^U+F703" => "makeBaseWritingDirectionLeftToRight:"
"@~ " => "cycleToNextInputKeyboardLayout:"
"@~^U+F701" => "makeTextWritingDirectionNatural:"
"@~^U+F702" => "makeTextWritingDirectionRightToLeft:"
"@~^U+F703" => "makeTextWritingDirectionLeftToRight:"
"@$U+F700" => "moveToBeginningOfDocumentAndModifySelection:"
"@$U+F701" => "moveToEndOfDocumentAndModifySelection:"
"@$U+F702" => "moveToLeftEndOfLineAndModifySelection:"
"@$U+F703" => "moveToRightEndOfLineAndModifySelection:"
"@U+F700" => "moveToBeginningOfDocument:"
"@U+F701" => "moveToEndOfDocument:"
"@U+F702" => "moveToLeftEndOfLine:"
"@U+F703" => "moveToRightEndOfLine:"
"^" => "noop:"
"^^C" => "insertLineBreak:"
"^^Y" => "selectPreviousKeyView:" //ctrl+shift+tab (remember that tab is ^I(0x09) and shift got its name because it shifts one bit?) (i forgot the source sorry! maybe checkout "things every hacker once knew")
"^^?" => "deleteBackwardByDecomposingPreviousCharacter:"
"^+" => "selectNextKeyView:"
"^
" => "insertLineBreak:"
"^^M" => "insertLineBreak:"
"^'" => "insertSingleQuoteIgnoringSubstitution:"
"^"" => "insertDoubleQuoteIgnoringSubstitution:"
"^/" => "insertRightToLeftSlash:"
"^$U+F702" => "moveToLeftEndOfLineAndModifySelection:"
"^$U+F703" => "moveToRightEndOfLineAndModifySelection:"
"^a" => "moveToBeginningOfParagraph:"
"^A" => "moveToBeginningOfParagraphAndModifySelection:"
"^b" => "moveBackward:"
"^B" => "moveBackwardAndModifySelection:"
"^d" => "deleteForward:"
"^e" => "moveToEndOfParagraph:"
"^E" => "moveToEndOfParagraphAndModifySelection:"
"^f" => "moveForward:"
"^F" => "moveForwardAndModifySelection:"
"^h" => "deleteBackward:"
"^k" => "deleteToEndOfParagraph:"
"^l" => "centerSelectionInVisibleArea:"
"^n" => "moveDown:"
"^N" => "moveDownAndModifySelection:"
"^o" => [
0 => "insertNewlineIgnoringFieldEditor:"
1 => "moveBackward:"
]
"^p" => "moveUp:"
"^P" => "moveUpAndModifySelection:"
"^t" => "transpose:"
"^v" => "pageDown:"
"^V" => "pageDownAndModifySelection:"
"^y" => "yank:"
"^U+F700" => "scrollPageUp:"
"^U+F701" => "scrollPageDown:"
"^U+F702" => "moveToLeftEndOfLine:"
"^U+F703" => "moveToRightEndOfLine:"
"~^C" => "insertNewlineIgnoringFieldEditor:"
"~^H" => "deleteWordBackward:"
"~^[" => "complete:"
"~^?" => "deleteWordBackward:"
"~+" => "insertTabIgnoringFieldEditor:"
"~
" => "insertNewlineIgnoringFieldEditor:"
"~^M" => "insertNewlineIgnoringFieldEditor:"
"~^^?" => "deleteWordBackward:"
"~^b" => "moveWordBackward:"
"~^B" => "moveWordBackwardAndModifySelection:"
"~^f" => "moveWordForward:"
"~^F" => "moveWordForwardAndModifySelection:"
"~$U+F700" => "moveParagraphBackwardAndModifySelection:"
"~$U+F701" => "moveParagraphForwardAndModifySelection:"
"~$U+F702" => "moveWordLeftAndModifySelection:"
"~$U+F703" => "moveWordRightAndModifySelection:"
"~U+F700" => [
0 => "moveBackward:"
1 => "moveToBeginningOfParagraph:"
]
"~U+F701" => [
0 => "moveForward:"
1 => "moveToEndOfParagraph:"
]
"~U+F702" => "moveWordLeft:"
"~U+F703" => "moveWordRight:"
"~U+F704" => "noop:"
"~U+F705" => "noop:"
"~U+F706" => "noop:"
"~U+F707" => "noop:"
"~U+F708" => "noop:"
"~U+F709" => "noop:"
"~U+F70A" => "noop:"
"~U+F70B" => "noop:"
"~U+F70C" => "noop:"
"~U+F70D" => "noop:"
"~U+F70E" => "noop:"
"~U+F70F" => "noop:"
"~U+F710" => "noop:"
"~U+F711" => "noop:"
"~U+F712" => "noop:"
"~U+F713" => "noop:"
"~U+F714" => "noop:"
"~U+F715" => "noop:"
"~U+F716" => "noop:"
"~U+F717" => "noop:"
"~U+F718" => "noop:"
"~U+F719" => "noop:"
"~U+F71A" => "noop:"
"~U+F71B" => "noop:"
"~U+F71C" => "noop:"
"~U+F71D" => "noop:"
"~U+F71E" => "noop:"
"~U+F71F" => "noop:"
"~U+F720" => "noop:"
"~U+F721" => "noop:"
"~U+F722" => "noop:"
"~U+F723" => "noop:"
"~U+F724" => "noop:"
"~U+F725" => "noop:"
"~U+F726" => "noop:"
"~U+F727" => "noop:"
"~U+F728" => "deleteWordForward:"
"~U+F729" => "noop:"
"~U+F72A" => "noop:"
"~U+F72B" => "noop:"
"~U+F72C" => "pageUp:"
"~U+F72D" => "pageDown:"
"~U+F72E" => "noop:"
"~U+F72F" => "noop:"
"~U+F730" => "noop:"
"~U+F731" => "noop:"
"~U+F732" => "noop:"
"~U+F733" => "noop:"
"~U+F734" => "noop:"
"~U+F735" => "noop:"
"~U+F736" => "noop:"
"~U+F737" => "noop:"
"~U+F738" => "noop:"
"~U+F739" => "noop:"
"~U+F73A" => "noop:"
"~U+F73B" => "noop:"
"~U+F73C" => "noop:"
"~U+F73D" => "noop:"
"~U+F73E" => "noop:"
"~U+F73F" => "noop:"
"~U+F740" => "noop:"
"~U+F741" => "noop:"
"~U+F742" => "noop:"
"~U+F743" => "noop:"
"~U+F744" => "noop:"
"~U+F745" => "noop:"
"~U+F746" => "noop:"
"~U+F747" => "noop:"
"$U+F700" => "moveUpAndModifySelection:"
"$U+F701" => "moveDownAndModifySelection:"
"$U+F702" => "moveLeftAndModifySelection:"
"$U+F703" => "moveRightAndModifySelection:"
"$U+F729" => "moveToBeginningOfDocumentAndModifySelection:"
"$U+F72B" => "moveToEndOfDocumentAndModifySelection:"
"$U+F72C" => "pageUpAndModifySelection:"
"$U+F72D" => "pageDownAndModifySelection:"
"U+F700" => "moveUp:"
"U+F701" => "moveDown:"
"U+F702" => "moveLeft:"
"U+F703" => "moveRight:"
"U+F704" => "noop:"
"U+F705" => "noop:"
"U+F706" => "noop:"
"U+F707" => "noop:"
"U+F708" => "complete:"
"U+F709" => "noop:"
"U+F70A" => "noop:"
"U+F70B" => "noop:"
"U+F70C" => "noop:"
"U+F70D" => "noop:"
"U+F70E" => "noop:"
"U+F70F" => "noop:"
"U+F710" => "noop:"
"U+F711" => "noop:"
"U+F712" => "noop:"
"U+F713" => "noop:"
"U+F714" => "noop:"
"U+F715" => "noop:"
"U+F716" => "noop:"
"U+F717" => "noop:"
"U+F718" => "noop:"
"U+F719" => "noop:"
"U+F71A" => "noop:"
"U+F71B" => "noop:"
"U+F71C" => "noop:"
"U+F71D" => "noop:"
"U+F71E" => "noop:"
"U+F71F" => "noop:"
"U+F720" => "noop:"
"U+F721" => "noop:"
"U+F722" => "noop:"
"U+F723" => "noop:"
"U+F724" => "noop:"
"U+F725" => "noop:"
"U+F726" => "noop:"
"U+F727" => "noop:"
"U+F728" => "deleteForward:"
"U+F729" => "scrollToBeginningOfDocument:"
"U+F72A" => "noop:"
"U+F72B" => "scrollToEndOfDocument:"
"U+F72C" => "scrollPageUp:"
"U+F72D" => "scrollPageDown:"
"U+F72E" => "noop:"
"U+F72F" => "noop:"
"U+F730" => "noop:"
"U+F731" => "noop:"
"U+F732" => "noop:"
"U+F733" => "noop:"
"U+F734" => "noop:"
"U+F735" => "noop:"
"U+F736" => "noop:"
"U+F737" => "noop:"
"U+F738" => "noop:"
"U+F739" => "delete:"
"U+F73A" => "noop:"
"U+F73B" => "noop:"
"U+F73C" => "noop:"
"U+F73D" => "noop:"
"U+F73E" => "noop:"
"U+F73F" => "noop:"
"U+F740" => "noop:"
"U+F741" => "noop:"
"U+F742" => "noop:"
"U+F743" => "noop:"
"U+F744" => "noop:"
"U+F745" => "noop:"
"U+F746" => "noop:"
"U+F747" => "noop:"
}
@hym3242
Copy link
Author

hym3242 commented Mar 13, 2024

don't forget defaults write -g NSRepeatCountBinding -string "^r" for emacs style numeric argument! (forgot the source!)

@hym3242
Copy link
Author

hym3242 commented Mar 13, 2024

see also "Keyboard Viewer" in your input source menu bar icon.

see also Ukelele.

@hym3242
Copy link
Author

hym3242 commented Mar 15, 2024

Don't forget option+esc to complete! (show possible completions of words) superhelpful! (especially for language learners!) unfortunately does not work in chrome. or for other languages.
Screenshot 2024-03-15 at 9 47 19 AM

@hym3242
Copy link
Author

hym3242 commented Mar 21, 2024

The setMark: and swapWithMark: can be very useful, but the mark is a bit unstable, can sometimes unexpectedly change to your current cursor position. In some apps setMark also remembers selection.

@hym3242
Copy link
Author

hym3242 commented Apr 4, 2024

It seems we can know about the defaults write -g NSRepeatCountBinding -string "^r" trick by just disassembling the AppKit...
Hopper Disassembler

@hym3242
Copy link
Author

hym3242 commented May 26, 2024

The best thing about this DefaultKeyBinding.dict in context of AppKit, is that you can bind keys to any method you discover in the AppKit internal debug menu's "Record Actions" window!(Although I don't really know how it works) For example, in Notes.app you can bind a key to "searchInNoteList:" and it will move key focus to the search field!!!(just like cmd+opt+f)

About the AppKit internal debug menu: defaults write -g NS🐞 -bool true. It's worth mentioning that I discovered this entirely on my own... though I am far from the first. (But that did not spoil the fun!)

Also follow the main text view's responder chain, and statically search for some useful methods of those classes in your disassembler. Methods you discovered in "Record Actions" that belong to classes not in your responder chain will not be usable.

@hym3242
Copy link
Author

hym3242 commented May 26, 2024

Notes.app cont'd:

Don't forget the subscript: and superscript:!!! OH MY GOD IS MACOS FUN AS FUCK TO HACK

…and the "moveSelectedListItemUp:" and "moveSelectedListItemDown:"

…and even some crazy shit like show/hide the sidebar toggleFolderListHidden:, and exportNoteAsPDF:

(Man, isn't this the pinnacle of the idea of object-oriented?)

@hym3242
Copy link
Author

hym3242 commented May 26, 2024

Notes.app cont'd again:

You may also want to make use of Notes.app's URL scheme (CFBundleURLSchemes in app Info.plist). e.g. notes://showNote?identifier=9AFFFFFF-FAFF-CAFE-BABE-8FFFFF2FEEF to create clickable links to other notes!

see also: https://www.reddit.com/r/shortcuts/comments/aot272/get_url_of_note_copy_note_url_to_clipboard
see also: https://discourse.hookproductivity.com/t/using-the-built-in-notes-url-scheme/6071

@hym3242
Copy link
Author

hym3242 commented Jun 17, 2024

Notes cont'd again again:

See also defaults write com.apple.Notes alexandria -bool YES. It will enable the .notesarchive export feature. This feature is already visible on iPad version of Notes (at least on Apple Store demo machines)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment