-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeybind.js
55 lines (48 loc) · 1.24 KB
/
keybind.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
$(function(){
var bookmark_titles = $('.bookmark_title');
var current_key = 0;
var cursor;
var max = bookmark_titles.length - 1;
$(document).keypress(function (e) {
var tagName;
if ($(':focus').get(0)) {
tagName = $(':focus').get(0).tagName;
}
if (tagName != 'INPUT' && tagName != 'TEXTAREA') {
//console.log(e.which);
switch (e.which) {
case 106: // j key
if (cursor !== undefined) {
cursor++;
if (cursor > max) {
cursor = max;
}
} else {
cursor = 0;
}
bookmark_titles[cursor].focus();
current_key = 106;
break;
case 107: // k key
cursor--;
if (cursor < 0) {
cursor = 0;
}
bookmark_titles[cursor].focus();
current_key = 107;
break;
case 111: // o key
window.open($(':focus').attr('href'), '_blank');
break;
case 113: // q key
$(':focus').parent().find('.quick_copy').click();
break;
case 115: // s key
$(':focus').parent().parent().find('div.star span').click();
break;
default:
break;
}
}
});
});