-
Notifications
You must be signed in to change notification settings - Fork 1
/
electron-shortcut.ts
124 lines (114 loc) · 4.2 KB
/
electron-shortcut.ts
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
'use strict';
var _localShortcut: any, localShortcut = () => { _localShortcut = _localShortcut || require('electron-localshortcut'); return _localShortcut; };
class FnShortcut implements yubo.FnShortcut {
constructor() {}
registerMainShortcut(win: Electron.BrowserWindow): void {
localShortcut().register(win, 'Command+P', () => {
win.webContents.send('shortcut', 'play');
});
localShortcut().register(win, 'Command+W', () => {
win.webContents.send('shortcut', 'stop');
});
localShortcut().register(win, 'Command+S', () => {
win.webContents.send('shortcut', 'record');
});
localShortcut().register(win, 'Command+Up', () => {
win.webContents.send('shortcut', 'moveToSource');
});
localShortcut().register(win, 'Command+Down', () => {
win.webContents.send('shortcut', 'moveToEncoded');
});
localShortcut().register(win, 'Command+Right', () => {
win.webContents.send('shortcut', 'encode');
});
localShortcut().register(win, 'Command+D', () => {
win.webContents.send('shortcut', 'fromClipboard');
});
localShortcut().register(win, 'Command+N', () => {
win.webContents.send('shortcut', 'putVoiceName');
});
localShortcut().register(win, 'Command+Left', () => {
win.webContents.send('shortcut', 'swichNextConfig');
});
localShortcut().register(win, 'Command+Shift+Left', () => {
win.webContents.send('shortcut', 'swichPreviousConfig');
});
localShortcut().register(win, 'Command+0', () => {
win.webContents.send('shortcut', 'swichNumberConfig', 0);
});
localShortcut().register(win, 'Command+1', () => {
win.webContents.send('shortcut', 'swichNumberConfig', 1);
});
localShortcut().register(win, 'Command+2', () => {
win.webContents.send('shortcut', 'swichNumberConfig', 2);
});
localShortcut().register(win, 'Command+3', () => {
win.webContents.send('shortcut', 'swichNumberConfig', 3);
});
localShortcut().register(win, 'Command+4', () => {
win.webContents.send('shortcut', 'swichNumberConfig', 4);
});
localShortcut().register(win, 'Command+5', () => {
win.webContents.send('shortcut', 'swichNumberConfig', 5);
});
localShortcut().register(win, 'Command+6', () => {
win.webContents.send('shortcut', 'swichNumberConfig', 6);
});
localShortcut().register(win, 'Command+7', () => {
win.webContents.send('shortcut', 'swichNumberConfig', 7);
});
localShortcut().register(win, 'Command+8', () => {
win.webContents.send('shortcut', 'swichNumberConfig', 8);
});
localShortcut().register(win, 'Command+9', () => {
win.webContents.send('shortcut', 'swichNumberConfig', 9);
});
}
registerHelpShortcut(win: Electron.BrowserWindow): void {
localShortcut().register(win, 'Command+W', () => {
win.close();
});
localShortcut().register(win, 'Up', () => {
win.webContents.send('shortcut', 'moveToPreviousHelp');
});
localShortcut().register(win, 'Down', () => {
win.webContents.send('shortcut', 'moveToNextHelp');
});
localShortcut().register(win, 'Command+Left', () => {
win.webContents.goBack();
});
localShortcut().register(win, 'Command+Right', () => {
win.webContents.goForward();
});
localShortcut().register(win, 'Command+F', () => {
win.webContents.send('shortcut', 'openSearchForm');
});
}
registerHelpSearchShortcut(win: Electron.BrowserWindow): void {
localShortcut().register(win, 'Command+W', () => {
win.hide();
});
}
registerSystemShortcut(win: Electron.BrowserWindow): void {
localShortcut().register(win, 'Command+W', () => {
win.close();
});
}
registerDictShortcut(win: Electron.BrowserWindow): void {
localShortcut().register(win, 'Command+W', () => {
win.close();
});
localShortcut().register(win, 'Command+S', () => {
win.webContents.send('shortcut', 'save');
});
localShortcut().register(win, 'Command+N', () => {
win.webContents.send('shortcut', 'add');
});
}
registerAboutShortcut(win: Electron.BrowserWindow): void {
localShortcut().register(win, 'Command+W', () => {
win.close();
});
}
}
export default FnShortcut;