File tree 4 files changed +236
-166
lines changed
4 files changed +236
-166
lines changed Original file line number Diff line number Diff line change
1
+ < html lang ="en ">
2
+ < head > </ head >
3
+ < body >
4
+ < input id ="hotkey " onkeyup ="keyUp(event) " />
5
+ < button id ="save " onclick ="saveHotkey() "> save</ button >
6
+ < script >
7
+ const Store = require ( 'electron-store' ) ;
8
+ const config = new Store ( ) ;
9
+
10
+ function loadHotkey ( ) {
11
+ document . getElementById ( "hotkey" ) . value = config . get ( "hotkey" ) ;
12
+ }
13
+ function saveHotkey ( ) {
14
+ const hotkey = document . getElementById ( "hotkey" ) . value ;
15
+ config . set ( "hotkey" , hotkey ) ;
16
+
17
+ require ( "electron" ) . ipcRenderer . send ( 'hotkeySet' ) ;
18
+ }
19
+ function keyUp ( event ) {
20
+ const keyCode = event . keyCode ;
21
+ const key = event . key ;
22
+ const charCode = event . code ;
23
+
24
+ if ( ( keyCode >= 16 && keyCode <= 18 ) || keyCode === 91 ) return ;
25
+
26
+ const value = [ ] ;
27
+ event . ctrlKey ? value . push ( "Control" ) : null ;
28
+ event . shiftKey ? value . push ( "Shift" ) : null ;
29
+ event . altKey ? value . push ( "Alt" ) : null ;
30
+ value . push ( key . toUpperCase ( ) ) ;
31
+
32
+ document . getElementById ( "hotkey" ) . value = value . join ( "+" ) ;
33
+ }
34
+ loadHotkey ( ) ;
35
+ </ script >
36
+ </ body >
37
+ </ html >
You can’t perform that action at this time.
0 commit comments