From 2ee29923c102c37ee7db78f440b25efbab7d3395 Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Fri, 11 Oct 2013 16:24:25 +0200 Subject: [PATCH] Fix keys quirks for different browsers --- index.html | 2 +- js/websockets.js | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index 377755c..6ef6436 100644 --- a/index.html +++ b/index.html @@ -18,7 +18,7 @@ - +

diff --git a/js/websockets.js b/js/websockets.js index 98f86e4..21c745b 100644 --- a/js/websockets.js +++ b/js/websockets.js @@ -497,11 +497,9 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', // Find next buffer with activity and switch to it angular.forEach($scope.buffers, function(buffer) { if(buffer.notification) { - console.log('a', buffer.id); $scope.setActiveBuffer(buffer.id); return false; }else if((parseInt(buffer.unread) || 0) > 0) { - console.log('b',buffer.id); $scope.setActiveBuffer(buffer.id); return false; } @@ -510,15 +508,19 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', } $scope.handleKeyPress = function($event) { + // Support different browser quirks + var code = $event.keyCode ? $event.keyCode : $event.charCode; + //console.log('keypress', $event.charCode, $event.altKey); + // Handle alt-a - if($event.altKey && $event.charCode == '97') { + if($event.altKey && (code == 97 || code == 65)) { $event.preventDefault(); $rootScope.switchToActivityBuffer(); return true; } // Handle ctrl-g - if($event.ctrlKey && $event.charCode == '103') { + if($event.ctrlKey && (code == 103 || code == 71)) { document.querySelector('#bufferFilter').focus(); return true; }