@@ -7,6 +7,9 @@ const BrowserWindow = electron.BrowserWindow;
7
7
const path = require ( 'path' ) ;
8
8
const url = require ( 'url' ) ;
9
9
10
+ // keyboard hook
11
+ const ioHook = require ( 'iohook' ) ;
12
+
10
13
// Keep a global reference of the window object, if you don't, the window will
11
14
// be closed automatically when the JavaScript object is garbage collected.
12
15
let mainWindow ;
@@ -30,7 +33,7 @@ function createWindow() {
30
33
} ) ;
31
34
mainWindow . loadURL ( startUrl ) ;
32
35
// Open the DevTools.
33
- // mainWindow.webContents.openDevTools();
36
+ mainWindow . webContents . openDevTools ( ) ;
34
37
35
38
// Emitted when the window is closed.
36
39
mainWindow . on ( 'closed' , function ( ) {
@@ -40,9 +43,17 @@ function createWindow() {
40
43
mainWindow = null
41
44
} )
42
45
43
- mainWindow . setSimpleFullScreen ( true ) ;
46
+ // mainWindow.setSimpleFullScreen(true);
44
47
mainWindow . setResizable ( false ) ;
45
- mainWindow . setIgnoreMouseEvents ( true ) ;
48
+ // mainWindow.setIgnoreMouseEvents(true);
49
+
50
+ mainWindow . on ( 'keyup' , ( event ) => {
51
+ console . log ( event ) ;
52
+ } ) ;
53
+
54
+ mainWindow . on ( 'keydown' , ( event ) => {
55
+ console . log ( event ) ;
56
+ } ) ;
46
57
47
58
}
48
59
@@ -70,3 +81,9 @@ app.on('activate', function () {
70
81
71
82
// In this file you can include the rest of your app's specific main process
72
83
// code. You can also put them in separate files and require them here.
84
+
85
+ ioHook . on ( "keyup" , event => {
86
+ console . log ( event ) ; // {keychar: 'f', keycode: 19, rawcode: 15, type: 'keup'}
87
+ } ) ;
88
+
89
+ ioHook . start ( ) ;
0 commit comments