Skip to content

Instantly share code, notes, and snippets.

@ryo1kato
Created May 6, 2013 13:17
Show Gist options
  • Select an option

  • Save ryo1kato/5525055 to your computer and use it in GitHub Desktop.

Select an option

Save ryo1kato/5525055 to your computer and use it in GitHub Desktop.
Disable annoying Chrome webapp shortcut for Emacs users! (e.g. MacOSX + Chrome + Google Spreadsheet.)
//Use https://chrome.google.com/webstore/detail/shortcut-manager/mgjjeipcdnnjhgodgjpfkffcejoljijf
//to assign key-shortcut to this JS snippet
function moveCaret(win, charCount) {
var sel;
sel = win.getSelection();
if (sel.rangeCount > 0) {
var textNode = sel.focusNode;
console.log(textNode)
var newOffset = sel.focusOffset + charCount;
sel.collapse(textNode, Math.min(textNode.length, newOffset));
}
}
moveCaret(window, 1) // 1 for Ctrl-F, -1 for Ctrl-B
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment