Skip to content

Commit fbc7da0

Browse files
committed
fix #448
1 parent 6315ec1 commit fbc7da0

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/main/common/registerHotKey.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,14 @@ const registerHotKey = (mainWindow: BrowserWindow): void => {
110110
// mainWindow.show();
111111
});
112112

113-
globalShortcut.register('CommandOrControl+W', () => {
114-
if (mainWindow && !mainWindow.isDestroyed() && mainWindow.isFocused()) {
115-
mainWindow.hide();
113+
// 添加局部快捷键监听
114+
mainWindow.webContents.on('before-input-event', (event, input) => {
115+
if (input.key.toLowerCase() === 'w'
116+
&& (input.control || input.meta) && !input.alt && !input.shift) {
117+
event.preventDefault();
118+
if (mainWindow && !mainWindow.isDestroyed()) {
119+
mainWindow.hide();
120+
}
116121
}
117122
});
118123

0 commit comments

Comments
 (0)