Skip to content

Commit c035376

Browse files
committed
test
1 parent 121716e commit c035376

File tree

4 files changed

+2257
-2234
lines changed

4 files changed

+2257
-2234
lines changed

electron-starter.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ const BrowserWindow = electron.BrowserWindow;
77
const path = require('path');
88
const url = require('url');
99

10+
// keyboard hook
11+
const ioHook = require('iohook');
12+
1013
// Keep a global reference of the window object, if you don't, the window will
1114
// be closed automatically when the JavaScript object is garbage collected.
1215
let mainWindow;
@@ -30,7 +33,7 @@ function createWindow() {
3033
});
3134
mainWindow.loadURL(startUrl);
3235
// Open the DevTools.
33-
// mainWindow.webContents.openDevTools();
36+
mainWindow.webContents.openDevTools();
3437

3538
// Emitted when the window is closed.
3639
mainWindow.on('closed', function () {
@@ -40,9 +43,17 @@ function createWindow() {
4043
mainWindow = null
4144
})
4245

43-
mainWindow.setSimpleFullScreen(true);
46+
// mainWindow.setSimpleFullScreen(true);
4447
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+
});
4657

4758
}
4859

@@ -70,3 +81,9 @@ app.on('activate', function () {
7081

7182
// In this file you can include the rest of your app's specific main process
7283
// 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

Comments
 (0)