Skip to content

Commit

Permalink
Merge pull request #1334 from fawce/keycuts
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fperez committed Jan 29, 2012
2 parents acf462e + d72bfdc commit 93bb469
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
5 changes: 3 additions & 2 deletions IPython/frontend/html/notebook/static/js/codecell.js
Expand Up @@ -70,7 +70,7 @@ var IPython = (function (IPython) {
if (this.read_only){
return false;
}

// note that we are comparing and setting the time to wait at each key press.
// a better wqy might be to generate a new function on each time change and
// assign it to CodeCell.prototype.request_tooltip_after_time
Expand All @@ -82,7 +82,8 @@ var IPython = (function (IPython) {
if(event.type === 'keydown' ){
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;
Expand Down
9 changes: 8 additions & 1 deletion IPython/frontend/html/notebook/static/js/notebook.js
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion IPython/frontend/html/notebook/static/js/textcell.js
Expand Up @@ -67,7 +67,7 @@ var IPython = (function (IPython) {
// handlers and is used to provide custom key handling. Its return
// value is used to determine if CodeMirror should ignore the event:
// true = ignore, false = don't ignore.

if (event.keyCode === 13 && (event.shiftKey || event.ctrlKey)) {
// Always ignore shift-enter in CodeMirror as we handle it.
return true;
Expand Down

0 comments on commit 93bb469

Please sign in to comment.