Skip to content
This repository
Browse code

Hitting esc then cmd+n gives control back to browser for tab shortcuts

  • Loading branch information...
commit 65b8e2532cd9cac82cf3823e63717fcfd7855708 1 parent fddef88
Remy Sharp authored April 02, 2013
12  public/js/editors/keycontrol.js
@@ -75,6 +75,8 @@ if (!customKeys.disabled) $document.keydown(function (event) {
75 75
   }
76 76
 });
77 77
 
  78
+var ignoreNextKey = false;
  79
+
78 80
 function keycontrol(event) {
79 81
   event = normalise(event);
80 82
 
@@ -91,6 +93,16 @@ function keycontrol(event) {
91 93
 
92 94
   var includeAltKey = customKeys.useAlt ? event.altKey : !event.altKey;
93 95
 
  96
+  if (event.which === 27 && !ignoreNextKey) {
  97
+    ignoreNextKey = true;
  98
+    return;
  99
+  } else if (ignoreNextKey && panelShortcuts[event.which] !== undefined && event.metaKey && includeAltKey) {
  100
+    ignoreNextKey = false;
  101
+    return;
  102
+  } else if (!event.metaKey) {
  103
+    ignoreNextKey = false;
  104
+  }
  105
+
94 106
   // these should fire when the key goes down
95 107
   if (event.type == 'keydown') {
96 108
     if (codePanel) {
32  views/index.html
@@ -292,13 +292,17 @@
292 292
       </thead>
293 293
       <tbody>
294 294
         <tr>
295  
-          <td>ctrl + [panel num]</td>
296  
-          <td>Show nth panel</td>
  295
+          <td>ctrl + [num]</td>
  296
+          <td>Toggle nth panel</td>
297 297
         </tr>
298 298
         <tr>
  299
+          <td>esc, ctrl + [num]</td>
  300
+          <td>JS Bin ignores this sequence, and returns control to browser shortcuts</td>
  301
+        </tr>
  302
+        <!--<tr>
299 303
           <td>ctrl + §<br />(or `)</td>
300 304
           <td>Hide focused panel</td>
301  
-        </tr>
  305
+        </tr>-->
302 306
         <tr>
303 307
           <td>ctrl + enter</td>
304 308
           <td>Re-render JavaScript.<br>If console visible: run JS in console</td>
@@ -309,31 +313,31 @@
309 313
         </tr>
310 314
         <tr>
311 315
           <td>ctrl + /</td>
312  
-          <td>Toggle comment on single line</td>
  316
+          <td>Toggle comment on selected lines</td>
313 317
         </tr>
314 318
         <!-- <tr>
315 319
           <td>ctrl + alt + .</td>
316 320
           <td>Close current HTML element</td>
317 321
         </tr> -->
318 322
         <tr>
319  
-          <td>tab</td>
320  
-          <td>Code complete (JavaScript only) and Emmet expand abbreviation</td>
  323
+          <td>cmd + [</td>
  324
+          <td>Indents selected lines</td>
321 325
         </tr>
322 326
         <tr>
323  
-          <td>ctrl + s</td>
324  
-          <td>Save current Bin</td>
  327
+          <td>cmd + ]</td>
  328
+          <td>Unindents selected lines</td>
325 329
         </tr>
326 330
         <tr>
327  
-          <td>ctrl + shift + s</td>
328  
-          <td>Clone current Bin</td>
  331
+          <td>tab</td>
  332
+          <td>Code complete (JavaScript only) &amp; Emmet expand</td>
329 333
         </tr>
330 334
         <tr>
331  
-          <td>cmd + [ (or tab)</td>
332  
-          <td>Indents selected lines</td>
  335
+          <td>ctrl + s</td>
  336
+          <td>Freeze current Bin</td>
333 337
         </tr>
334 338
         <tr>
335  
-          <td>cmd + ] (or shift + tab)</td>
336  
-          <td>Unindents selected lines</td>
  339
+          <td>ctrl + shift + s</td>
  340
+          <td>Clone current Bin</td>
337 341
         </tr>
338 342
 
339 343
         <tr><td colspan="2"><small><br>JS Bin also supports <a href="http://docs.emmet.io/" target="_blank">Emmet/Zen Coding</a> shortcuts</small></td></tr>

0 notes on commit 65b8e25

Please sign in to comment.
Something went wrong with that request. Please try again.