修复快速跳转问题,设定一个计时器3秒后默认你抬起按键

This commit is contained in:
luchenqun 2018-07-16 11:49:21 +08:00
parent 012a45a006
commit 81299ab1b3
1 changed files with 6 additions and 1 deletions

View File

@ -229,11 +229,15 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time
// 在输入文字的时候也会触发所以不要用Ctrl,Shift之类的按键 // 在输入文字的时候也会触发所以不要用Ctrl,Shift之类的按键
$document.bind("keydown", function (event) { $document.bind("keydown", function (event) {
console.info('keydown', event.key.toUpperCase(), $scope.quickUrl);
$scope.$apply(function () { $scope.$apply(function () {
var key = event.key.toUpperCase(); var key = event.key.toUpperCase();
if (key == 'CONTROL' || key == 'SHIFT' || key == 'ALT') { if (key == 'CONTROL' || key == 'SHIFT' || key == 'ALT') {
$scope.longPress = true; $scope.longPress = true;
// 有时候没有检测到keyup会一直按无效干脆过个3秒就认为你抬起来了
// 反正你按下我还是会给你标记为true的。
$timeout(function () {
$scope.longPress = false;
}, 3000)
} }
if (dataService.keyShortcuts()) { if (dataService.keyShortcuts()) {
@ -260,6 +264,7 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time
// 数字键用来切换菜单 // 数字键用来切换菜单
if (!isNaN(key)) { if (!isNaN(key)) {
var num = parseInt(key); var num = parseInt(key);
if(num < 0 || num > 6) return;
pubSubService.publish('Common.menuActive', { pubSubService.publish('Common.menuActive', {
login: $scope.login, login: $scope.login,
index: num - 1 index: num - 1