5
브라우저 창 내에서 backspace
키의 back()
기능을 비활성화하는 방법을 알아 보려면 interwebz 및 Atom-shell 문서를 수색했습니다.Atom-shell에서 백 스페이스 비활성화
브라우저 (브라우저)를 사용하지 않고 브라우저 창 수준 대신 응용 프로그램 수준에서 더 많은 것을 사용하는 것을 선호합니다.
브라우저 창 내에서 backspace
키의 back()
기능을 비활성화하는 방법을 알아 보려면 interwebz 및 Atom-shell 문서를 수색했습니다.Atom-shell에서 백 스페이스 비활성화
브라우저 (브라우저)를 사용하지 않고 브라우저 창 수준 대신 응용 프로그램 수준에서 더 많은 것을 사용하는 것을 선호합니다.
onkeydown
청취자없이이 작업을 수행하는 유일한 방법은 전역 단축키와 Electron API의 ipc 이벤트입니다. 글로벌 바로 가기 어떤 키를 비활성화
첫 번째 부인 ...
정말 컴퓨터에 전 세계적으로 그것을 사용하지 않습니다! 글로벌 단축키 사용시주의하십시오! 바로 가기 등록을 잊어 버리거나 올바르게 처리하지 않으면 백 스페이스를 사용하지 않고 실수를 수정하기가 어렵습니다. 이 같은 IPC "전환"이벤트 핸들러 내부의 바로 가기를 추가 할 수
또는const { app, ipcMain,
globalShortcut,
BrowserWindow,
} = require('electron');
app.on('ready',() => {
// Create the browser window
let mainWindow = new BrowserWindow({width: 800, height: 600});
// and load the index.html of the app
mainWindow.loadUrl('file://' + __dirname + '/index.html');
// Register a 'Backspace' shortcut listener when focused on window
mainWindow.on('focus',() => {
if (mainWindow.isFocused()) {
globalShortcut.register('Backspace',() => {
// Provide feedback or logging here
// If you leave this section blank, you will get no
// response when you try the shortcut (i.e. Backspace).
console.log('Backspace was pressed!'); //comment-out or delete when ready.
});
});
});
// ** THE IMPORTANT PART **
// Unregister a 'Backspace' shortcut listener when leaving window.
mainWindow.on('blur',() => {
globalShortcut.unregister('Backspace');
console.log('Backspace is unregistered!'); //comment-out or delete when ready.
});
});
이 나를 위해 일한 것입니다 말했다
...
// In the main process
ipcMain.on('disableKey-toggle', (event, keyToDisable) => {
if (!globalShortcut.isRegistered(keyToDisable){
globalShortcut.register(keyToDisable,() => {
console.log(keyToDisable+' is registered!'); //comment-out or delete when ready.
});
} else {
globalShortcut.unregister(keyToDisable);
console.log(keyToDisable+' is unregistered!'); //comment-out or delete when ready.
}
});
// In the render process send the accelerator of the keyToDisable.
// Here we use the 'Backspace' accelerator.
const { ipcRenderer } = require('electron');
ipcRenderer.send('disableKey-toggle', 'Backspace');
왜 당신에게 것 전체 애플리케이션의 백 스페이스 키를 차단 하시겠습니까? "정상적인"자바 스크립트로 프론트 엔드/렌더러에서 막을 수 있습니다 (여기 또는 그 대답 아래의 유사한 대답). [here on stackoverflow] (http://stackoverflow.com/a/2768256/1435377). :) 주제 초보자가 nodejs 방법을 요청했는지 ... 여전히 이유를 모르겠다 - 사람들은이 방법을 계속 염두에 두어야한다 ... (: –
나는 보통 이것이 가장 쉬운 방법이다. 이 질문은 Electron과 * not * Javascript를 사용하여 어떻게해야하는지 질문했습니다. 더 적용 가능한 사용 사례가있을 것이라고 상상합니다 : 다른 응용 프로그램이나 시스템 대화 상자에서 키를 가로 채고 (차단하지 않고) 계속하려는 경우 -프레스. – Josh