KeyRemap4MacBook
I knew I had seen this somewhere…
All you need to do is install KeyRemap4Macbook.
From the "implicit behavior" section:
Share state of modifier keys with all connected keyboards:
When you are using multiple keyboards, modifier keys are shared with all keyboards.
For example, pressing "shift key on keyboard1" and "space key on keyboard2" sends shift-space.
Yes, it works on other Macs too, not just MacBooks.
Karabiner comes with everything you need—a way to define a shortcut, and a way to move the mouse. The warp-mouse-cursor-position
utility lives in /Applications/Karabiner.app/Contents/Library/utilities/bin/
.
It has a default setting to warp the mouse to the center of the current window by tapping fn or holding ' or /, but for a customized version, add this to your ~/Library/Application Support/Karabiner/private.xml
: (After you’re done, go into Karabiner’s preferences and check the box inside Mouse Warping.)
<item>
<name>Mouse Warping</name>
<vkopenurldef>
<name>KeyCode::VK_OPEN_URL_SHELL_mousetowindowcenter</name>
<url type="shell">
<![CDATA[
/Applications/Karabiner.app/Contents/Library/utilities/bin/warp-mouse-cursor-position front_window middle 0 center 0
]]>
</url>
</vkopenurldef>
<item>
<identifier>private.f14_mousetowindowcenter</identifier>
<name>F14 to move the mouse to the center of the current window</name>
<autogen>
--KeyToKey--
KeyCode::F14,
KeyCode::VK_OPEN_URL_SHELL_mousetowindowcenter
</autogen>
</item>
</item>
With Karabiner's utility, you can use the screen
option like this:
warp-mouse-cursor-position screen NUM VERTICAL X_OFFSET HORIZONTAL Y_OFFSET
VERTICAL
can be top
, middle
, or bottom
, and HORIZONTAL
can be left
, center
, or right
.
X_OFFSET
and Y_OFFSET
can be numerical values, like +10
or -10
. Just be careful to put the arguments in the right order—they seem oddly switched.
(For the front window, just use front_window
instead of screen
.)
Probably the most popular way, but in order to use it for moving to the middle of a window, you’d need an AppleScript to get the bounds of the current window, then calculate the center, etc.
Best Answer
There is no shortcut for it by default. As a hack, you can create
~/Library/KeyBindings/
and save a property list like this as~/Library/KeyBindings/DefaultKeyBinding.dict
:Then quit and reopen applications to apply the changes.
~m
is option-m, which is bound toback-to-indentation
in Emacs.I copied the macro from https://github.com/ttscoff/KeyBindings/blob/master/DefaultKeyBinding.dict.
moveToBeginningOfParagraph:, selectWord:, moveRight:
would not work with lines that don't start with spaces or tabs.moveToBeginningOfParagraph:,moveWordRight:, moveWordLeft:
would not work with some lines where the first non-whitespace character is a special character.DefaultKeyBinding.dict does not work with some applications like Xcode or Firefox.
See http://www.hcs.harvard.edu/~jrus/site/cocoa-text.html or http://osxnotes.net/keybindings.html for more information.