Permalink
Browse files

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

  • Loading branch information...
remy committed Apr 2, 2013
1 parent fddef88 commit 65b8e2532cd9cac82cf3823e63717fcfd7855708
Showing with 30 additions and 14 deletions.
  1. +12 −0 public/js/editors/keycontrol.js
  2. +18 −14 views/index.html
@@ -75,6 +75,8 @@ if (!customKeys.disabled) $document.keydown(function (event) {
}
});
+var ignoreNextKey = false;
+
function keycontrol(event) {
event = normalise(event);
@@ -91,6 +93,16 @@ function keycontrol(event) {
var includeAltKey = customKeys.useAlt ? event.altKey : !event.altKey;
+ if (event.which === 27 && !ignoreNextKey) {
+ ignoreNextKey = true;
+ return;
+ } else if (ignoreNextKey && panelShortcuts[event.which] !== undefined && event.metaKey && includeAltKey) {
+ ignoreNextKey = false;
+ return;
+ } else if (!event.metaKey) {
+ ignoreNextKey = false;
+ }
+
// these should fire when the key goes down
if (event.type == 'keydown') {
if (codePanel) {
View
@@ -292,13 +292,17 @@ <h2>Keyboard Shortcuts</h2>
</thead>
<tbody>
<tr>
- <td>ctrl + [panel num]</td>
- <td>Show nth panel</td>
+ <td>ctrl + [num]</td>
+ <td>Toggle nth panel</td>
</tr>
<tr>
+ <td>esc, ctrl + [num]</td>
+ <td>JS Bin ignores this sequence, and returns control to browser shortcuts</td>
+ </tr>
+ <!--<tr>
<td>ctrl + §<br />(or `)</td>
<td>Hide focused panel</td>
- </tr>
+ </tr>-->
<tr>
<td>ctrl + enter</td>
<td>Re-render JavaScript.<br>If console visible: run JS in console</td>
@@ -309,31 +313,31 @@ <h2>Keyboard Shortcuts</h2>
</tr>
<tr>
<td>ctrl + /</td>
- <td>Toggle comment on single line</td>
+ <td>Toggle comment on selected lines</td>
</tr>
<!-- <tr>
<td>ctrl + alt + .</td>
<td>Close current HTML element</td>
</tr> -->
<tr>
- <td>tab</td>
- <td>Code complete (JavaScript only) and Emmet expand abbreviation</td>
+ <td>cmd + [</td>
+ <td>Indents selected lines</td>
</tr>
<tr>
- <td>ctrl + s</td>
- <td>Save current Bin</td>
+ <td>cmd + ]</td>
+ <td>Unindents selected lines</td>
</tr>
<tr>
- <td>ctrl + shift + s</td>
- <td>Clone current Bin</td>
+ <td>tab</td>
+ <td>Code complete (JavaScript only) &amp; Emmet expand</td>
</tr>
<tr>
- <td>cmd + [ (or tab)</td>
- <td>Indents selected lines</td>
+ <td>ctrl + s</td>
+ <td>Freeze current Bin</td>
</tr>
<tr>
- <td>cmd + ] (or shift + tab)</td>
- <td>Unindents selected lines</td>
+ <td>ctrl + shift + s</td>
+ <td>Clone current Bin</td>
</tr>
<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 comments on commit 65b8e25

Please sign in to comment.