Chevereto 更改图像预览快捷键

在查看图像预览的时候,关闭图片的快捷键是 “X” ,而我们想使用 “Esc” 键代替它,

作者 Rodolfo 给出的方案是:

  • 可在第 #L2709 88: 'close' 修改为 27: 'close'
//原代码
    keys: {
        83: 'select',
        76: 'like',
        70: 'flag',
        69: 'edit',
        65: 'move',
        46: 'delete',
        88: 'close', //<--- 此处需要修改 (88=>27)
        37: 'prev',
        39: 'next',
    },
        
//修改后
    keys: {
        83: 'select',
        76: 'like',
        70: 'flag',
        69: 'edit',
        65: 'move',
        46: 'delete',
        27: 'close',
        37: 'prev',
        39: 'next',
    },        
  • 在第 #L2596 处,将 var direct = [88, 37, 39]; 修改成 var direct = [27, 37, 39];
//原代码
$(document).on("keyup", function (e) {
        if (
            $(PF.obj.modal.selectors.root).exists() ||
            !($(".viewer").exists() && e.which in CHV.fn.listingViewer.keys)
        ) {
            return;
        }
        var direct = [88, 37, 39]; // X <- -> //<--- 此处需要修改 (88=>27)
        var action = CHV.fn.listingViewer.keys[e.which];
        if (direct.indexOf(e.which) == -1) {
            $(
                "[data-action=" + action + "]",
                CHV.fn.listingViewer.selectors.root
            ).click();
        } else {
            if (action in CHV.fn.listingViewer) {
                CHV.fn.listingViewer[action]();
            }
        }
    }

//修改后

$(document).on("keyup", function (e) {
        if (
            $(PF.obj.modal.selectors.root).exists() ||
            !($(".viewer").exists() && e.which in CHV.fn.listingViewer.keys)
        ) {
            return;
        }
        var direct = [27, 37, 39]; // X <- ->
        var action = CHV.fn.listingViewer.keys[e.which];
        if (direct.indexOf(e.which) == -1) {
            $(
                "[data-action=" + action + "]",
                CHV.fn.listingViewer.selectors.root
            ).click();
        } else {
            if (action in CHV.fn.listingViewer) {
                CHV.fn.listingViewer[action]();
            }
        }
    }

对应键代码详细如下表

In every browser there are three possible kinds of client-side events triggered when a keyboard key is pressed or released:

  1. keydown event
  2. keypress event
  3. keyup event

The keydown event occurs when the keyboard key is pressed, and it is followed at once by the execution of keypress event.
The keyup event is generated when the key is released.

Here is a sample program using the keycodes You can view it's source to the the actual coding

Keyboard key PressedJavaScript Key Code value
backspace8
tab9
enter13
shift16
ctrl17
alt18
pause/break19
caps lock20
escape27
page up33
Space32
page down34
end35
home36
arrow left37
arrow up38
arrow right39
arrow down40
print screen44
insert45
delete46
048
149
250
351
452
553
654
755
856
957
a65
b66
c67
d68
e69
f70
g71
h72
i73
j74
k75
l76
m77
n78
o79
p80
q81
r82
s83
t84
u85
v86
w87
x88
y89
z90
left window key91
right window key92
select key93
numpad 096
numpad 197
numpad 298
numpad 399
numpad 4100
numpad 5101
numpad 6102
numpad 7103
numpad 8104
numpad 9105
multiply106
add107
subtract109
decimal point110
divide111
f1112
f2113
f3114
f4115
f5116
f6117
f7118
f8119
f9120
f10121
f11122
f12123
num lock144
scroll lock145
My Computer (multimedia keyboard)182
My Calculator (multimedia keyboard)183
semi-colon186
equal sign187
comma188
dash189
period190
forward slash191
open bracket219
back slash220
close braket221
single quote222

来源:http://gcctech.org/csc/javascript/javascript_keycodes.htm

松鼠大大

若不是真的废物,谁又愿意混吃等死呢?

6 条评论

  1. yml

    试过两次了 但是都只改了一处的值,两次修改后均不正常 尝试修改两个值,看看会不会正常

    • yml

      @yml 修改两处也是白屏 别的没动

  2. yml

    1.4 修改后会出错 白屏或黑屏

    • @yml 看了下,最新的是需要修改两处键代码值的,我在3.20测试可以用,白屏或者黑屏,是否为你修改js文件时出现了问题?

  3. 然后水了一整页的键位表 ::funny:04::

发表评论

您的电子邮件地址不会被公开,必填项已用*标注。

相关推荐