To map the application key to right-click using Karabiner-Elements one can use:
"simple_modifications": [
{
"from": {
"key_code": "application"
},
"to": {
"pointing_button": "button2"
}
},
However, this will perform a right-click at the position of the mouse pointer. I want it to move the pointer to the position of the caret and then perform the right-click.
Presumably, to do this I need to use "complex_modifications" rule.
My main problem is I don't know how to change the mouse pointer position to the caret position.
Using AutoHotkey there's an answer here Moving the mouse pointer to the cursor
I can't say I really understand the answer there but anyway I'm looking to do this with Karabiner-Elements
I think that you can move the mouse cursor to a specified position in newer 13+ versions of Karabiner-Elements (which I can't use with MacOS High Sierra).
I fear though, that it's very difficult to get x- an y-values of a selection, first.
BUT:
You can use the AppleScript UI attribute "AXFocusedUIElement" to right-click on selected UI elements.
(This DOES work fine for Finder windows files&folders and TextEdit selections, e.g., but sadly does not for Safari selections and files on Finder's desktop.)
If your main goal is to navigate inside Finder's windows this script* works perfectly.
Notice that the entire osascript ( "osascript -e ' … >> … end tell'" ) needs to be a one-liner (I inserted "_/¯" for better readability).
(* the AppleScript "tell application … end tell" part is found in several variations on the net.
AND: Of course you can change my Ctrl-LeftArrow shortcut to any one you like.)