Double-tap escape to disconnect

This commit is contained in:
Lorenz Hübschle-Schneider 2014-04-19 14:13:32 +02:00
parent 5d2bb70e26
commit 16664cefc0
2 changed files with 8 additions and 4 deletions

View File

@ -113,7 +113,7 @@
<li>ALT-a: Focus on next buffer with activity</li> <li>ALT-a: Focus on next buffer with activity</li>
<li>ALT-&lt;: Switch to previous buffer</li> <li>ALT-&lt;: Switch to previous buffer</li>
<li>ALT-g: Focus on buffer list filter</li> <li>ALT-g: Focus on buffer list filter</li>
<li>Esc: disconnect</li> <li>Esc-Esc: disconnect (double-tap)</li>
<li>arrow keys: history navigation</li> <li>arrow keys: history navigation</li>
</ul> </ul>
</div> </div>

View File

@ -1080,7 +1080,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
if ($rootScope.connected) { if ($rootScope.connected) {
event.preventDefault(); event.preventDefault();
// Chrome requires us to set this or it will not show the dialog // Chrome requires us to set this or it will not show the dialog
event.returnValue = "You have an active connection to your WeeChat relay. Please disconnect using the button in the top-right corner or by pressing the Escape key."; event.returnValue = "You have an active connection to your WeeChat relay. Please disconnect using the button in the top-right corner or by double-tapping the Escape key.";
} }
$scope.favico.reset(); $scope.favico.reset();
}; };
@ -1273,10 +1273,14 @@ weechat.directive('inputBar', function() {
} }
} }
// Escape -> disconnect // Double-tap Escape -> disconnect
if (code === 27) { if (code === 27) {
$event.preventDefault(); $event.preventDefault();
if (typeof $scope.lastEscape !== "undefined" && (Date.now() - $scope.lastEscape) <= 500) {
// Double-tap
connection.disconnect(); connection.disconnect();
}
$scope.lastEscape = Date.now();
return true; return true;
} }