'TypeError: Cannot read properties of undefined (reading 'webContents') Electron.JS
Im trying to make an event on keyPress (keyDown) (In electron) but i get this error.
TypeError: Cannot read properties of undefined (reading 'webContents')
Here is my code:
const { app, BrowserWindow, Menu, Tray, Notification, globalShortcut, webContents } = require('electron')
win = new BrowserWindow({
autoHideMenuBar: false,
width: 700,
height: 830,
resizable: false,
titleBarStyle: 'hidden',
titleBarOverlay: {
color: '#2f3241',
symbolColor: '#e2c890'
},
frame: false,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
nodeIntegration: true,
contextIsolation: false
}
})
//This
win.webContents.on("before-input-event", (event, input) => {
console.log(input);
});
//-----
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
