ソースを参照

Allow saving changes by Ctrl-S or Cmd-S

Benoît Hubert 8 年 前
コミット
e8d26af799
1 ファイル変更11 行追加2 行削除
  1. 11 2
      js/ws-editor.js

+ 11 - 2
js/ws-editor.js

@@ -42,7 +42,17 @@ $(document).ready(function() {
 
   });
 
-
+// https://stackoverflow.com/questions/93695/best-cross-browser-method-to-capture-ctrls-with-jquery#answer-14180949
+  $(window).bind('keydown', function(event) {
+    if (event.ctrlKey || event.metaKey) {
+      switch (String.fromCharCode(event.which).toLowerCase()) {
+      case 's':
+        event.preventDefault();
+        (onSaveChanges.bind(_ws.ui.tabs))();
+        break;
+      }
+    }
+  });
 
   // /**
   //  * Make the left panel resizable
@@ -160,7 +170,6 @@ $(document).ready(function() {
       // // saveTimeout2 = setTimeout(saveChanges, 1000);
     },
 
-
     render: function() {
       // console.log('render editor', this);
       setDefaultEditorContent();