##// END OF EJS Templates
Adding keyboard shortcuts.
Brian E. Granger -
Show More
@@ -22,6 +22,7 var IPython = (function (IPython) {
22 22 this.dirty = false;
23 23 this.msg_cell_map = {};
24 24 this.metadata = {};
25 this.control_key_active = false;
25 26 this.style();
26 27 this.create_elements();
27 28 this.bind_events();
@@ -71,6 +72,68 var IPython = (function (IPython) {
71 72 } else if (event.which === 13 && event.ctrlKey) {
72 73 that.execute_selected_cell({terminal:true});
73 74 return false;
75 } else if (event.which === 77 && event.ctrlKey) {
76 console.log("Activating control key")
77 that.control_key_active = true;
78 return false;
79 } else if (event.which === 68 && that.control_key_active) {
80 // Delete selected cell = d
81 that.delete_cell();
82 that.control_key_active = false;
83 return false;
84 } else if (event.which === 65 && that.control_key_active) {
85 // Insert code cell after selected = a
86 that.insert_code_cell_after();
87 that.control_key_active = false;
88 return false;
89 } else if (event.which === 66 && that.control_key_active) {
90 // Insert code cell before selected = a
91 that.insert_code_cell_before();
92 that.control_key_active = false;
93 return false;
94 } else if (event.which === 67 && that.control_key_active) {
95 // To code = c
96 that.to_code();
97 that.control_key_active = false;
98 return false;
99 } else if (event.which === 77 && that.control_key_active) {
100 // To markdown = m
101 that.to_markdown();
102 that.control_key_active = false;
103 return false;
104 } else if (event.which === 84 && that.control_key_active) {
105 // Toggle output = t
106 that.toggle_output();
107 that.control_key_active = false;
108 return false;
109 } else if (event.which === 83 && that.control_key_active) {
110 // Save notebook = s
111 IPython.save_widget.save_notebook();
112 that.control_key_active = false;
113 return false;
114 } else if (event.which === 74 && that.control_key_active) {
115 // Move cell down = j
116 that.move_cell_down();
117 that.control_key_active = false;
118 return false;
119 } else if (event.which === 75 && that.control_key_active) {
120 // Move cell up = k
121 that.move_cell_up();
122 that.control_key_active = false;
123 return false;
124 } else if (event.which === 38 && that.control_key_active) {
125 // Select previous = up arrow
126 that.select_prev();
127 that.control_key_active = false;
128 return false;
129 } else if (event.which === 40 && that.control_key_active) {
130 // Select next = down arrow
131 that.select_next();
132 that.control_key_active = false;
133 return false;
134 } else if (that.control_key_active) {
135 that.control_key_active = false;
136 return true;
74 137 };
75 138 });
76 139
@@ -39,9 +39,7 var IPython = (function (IPython) {
39 39 SaveWidget.prototype.bind_events = function () {
40 40 var that = this;
41 41 this.element.find('button#save_notebook').click(function () {
42 IPython.notebook.save_notebook();
43 that.set_document_title();
44 that.last_saved_name = that.get_notebook_name();
42 that.save_notebook();
45 43 });
46 44 this.element.find('input#notebook_name').keyup(function () {
47 45 that.is_renaming();
@@ -49,6 +47,13 var IPython = (function (IPython) {
49 47 };
50 48
51 49
50 SaveWidget.prototype.save_notebook = function () {
51 IPython.notebook.save_notebook();
52 this.set_document_title();
53 this.last_saved_name = this.get_notebook_name();
54 };
55
56
52 57 SaveWidget.prototype.is_renaming = function () {
53 58 if (this.get_notebook_name() !== this.last_saved_name) {
54 59 this.status_rename();
General Comments 0
You need to be logged in to leave comments. Login now