Merge pull request #1334 from fawce/keycuts

Make Control-S (or Cmd-S on Apple) save the actual notebook instead of bringing up the useless 'save as html' dialog.  This doesn't disable the C-m-s keybinding, simply adds the far more familiar and common C-s.
This commit is contained in:
Fernando Perez 2012-01-28 16:39:06 -08:00
commit 5067e77292
3 changed files with 12 additions and 4 deletions

View File

@ -83,6 +83,7 @@ var IPython = (function (IPython) {
that.remove_and_cancel_tooltip();
}
if (event.keyCode === 13 && (event.shiftKey || event.ctrlKey)) {
// Always ignore shift-enter in CodeMirror as we handle it.
return true;

View File

@ -62,7 +62,14 @@ var IPython = (function (IPython) {
$(document).keydown(function (event) {
// console.log(event);
if (that.read_only) return true;
if (event.which === 27) {
// Save (CTRL+S) or (AppleKey+S)
//metaKey = applekey on mac
if ((event.ctrlKey || event.metaKey) && event.keyCode==83) {
IPython.save_widget.save_notebook();
event.preventDefault();
return false;
} else if (event.which === 27) {
// Intercept escape at highest level to avoid closing
// websocket connection with firefox
event.preventDefault();