Apple - Vim/Emacs keybinding for `Preview.app`
As @tty suggested, using Karabiner is brilliant. I made some extra rules.
You can navigate using HJKL and zoom using FDER. Read the file for more information.
Here is my private.xml
:
<?xml version="1.0"?>
<root>
<appdef>
<appname>PREVIEW</appname>
<equal>com.apple.Preview</equal>
</appdef>
<item>
<name>Vi Navigation in Preview</name>
<identifier>private.preview.vinav</identifier>
<only>PREVIEW</only>
<uielementrole_not>AXTextField, AXTextArea</uielementrole_not>
<modifier_only>
ModifierFlag::NONE,
ModifierFlag::SHIFT_L | ModifierFlag::NONE,
ModifierFlag::SHIFT_R | ModifierFlag::NONE,
</modifier_only>
<appendix>Navigate using the HJKL keys</appendix>
<autogen>__KeyToKey__ KeyCode::J, KeyCode::CURSOR_DOWN</autogen>
<autogen>__KeyToKey__ KeyCode::K, KeyCode::CURSOR_UP</autogen>
<autogen>__KeyToKey__ KeyCode::H, KeyCode::CURSOR_LEFT</autogen>
<autogen>__KeyToKey__ KeyCode::L, KeyCode::CURSOR_RIGHT</autogen>
</item>
<item>
<name>Vi Zoom in Preview</name>
<identifier>private.preview.vizoom</identifier>
<only>PREVIEW</only>
<uielementrole_not>AXTextField, AXTextArea</uielementrole_not>
<modifier_only>
ModifierFlag::NONE,
ModifierFlag::SHIFT_L | ModifierFlag::NONE,
ModifierFlag::SHIFT_R | ModifierFlag::NONE,
</modifier_only>
<appendix>Zoom using E/R: out/in</appendix>
<appendix>Zoom to fit: F</appendix>
<appendix>Zoom to 100%: D</appendix>
<autogen>__KeyToKey__ KeyCode::F, KeyCode::KEYPAD_9, VK_COMMAND</autogen>
<autogen>__KeyToKey__ KeyCode::D, KeyCode::KEYPAD_0, VK_COMMAND</autogen>
<autogen>__KeyToKey__ KeyCode::R, KeyCode::KEYPAD_PLUS, VK_COMMAND</autogen>
<autogen>__KeyToKey__ KeyCode::E, KeyCode::KEYPAD_MINUS, VK_COMMAND</autogen>
</item>
</root>
You can edit the "Up" and "Down" keyboard shortcuts by going to System Preferences / Keyboard / Application Shortcuts, add a new shortcut for Preview.app. I've mapped Option-J to down, Option-K to up. It won't let you map just J and K, for some reason. But at least you can now browse a PDF without leaving the home row.
Use this
Very excellent!!!
I found it recently.
https://pqrs.org/macosx/keyremap4macbook/index.html.en